[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Simple Traits

Ethan Furman

3/27/2010 1:13:00 PM

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/st...

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~