[Python-Dev] Things to Know About Super (original) (raw)

Michele Simionato michele.simionato at gmail.com
Wed Aug 27 08:02:47 CEST 2008


On Tue, Aug 26, 2008 at 11:10 PM, Steve Holden <steve at holdenweb.com> wrote:

If you aren't aware of it you should take a look at Enthought's traits package. It's part of the Enthought Tool Suite (ETS).

I know of the existence of that framework, however it is quite large and I don't see the relation with the concept of traits I have in mind, which is more or less the one described here: http://www.iam.unibe.ch/%7Escg/Archive/Papers/Scha03aTraits.pdf

Basically, these are the properties of traits:

  1. the methods/attributes in a trait go logically together;
  2. if a trait enhances a class, then all subclasses are enhanced too;
  3. if a trait has methods in common with the class, then the methods defined in the class have the precedence;
  4. the ordering of traits is not important, i.e. enhancing a class first with trait T1 and then with trait T2 or viceversa is the same;
  5. if traits T1 and T2 have names in common, enhancing a class both with T1 and T2 raises an error unless there is an explicitoverriding;
  6. if a trait has methods in common with the base class, then the trait methods have the precedence;

Properties from 4 to 6 are the distinguishing properties of traits with respect to multiple inheritance and mixins.



More information about the Python-Dev mailing list