Simple Traits

E

Ethan Furman

Wow.

I just stumbled across one of Michele Simionato's offerings, called
simple traits (strait for short) which looks *really* cool.

You can find it here: http://pypi.python.org/pypi/strait/0.5.1

Extremely quick summary:

Instead of multiple inheritance, with it's range of problems, use single
inheritance for the basics, and include traits for various extra
functionality that you want your class to have.

As a side note, one of his blog entries at Artima talks about using
composition instead of mixins when constructing a class, e.g. by doing:

class foo(object):
import baz
def __init__(self):
self.baz.do_something()

which has the benefit (over mixins) of avoiding name-space pollution, as
well as being able to tell where your methods are coming from. The cool
thing (to me, at least) was the realization of being able to use import
statements in class construction.

Thanks, Michele!!

~Ethan~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top