[SciPy-dev] Subclassing Traits

Peter Wang pwang at enthought.com
Wed Dec 28 09:30:38 CST 2005

Paul Barrett wrote ..
> Could someone provide an example of how to subclass the enthought Traits
> class?  I'd like to add a couple of attributes to the class, e.g. a units
> attribute.

Hi Paul,

Do you mean subclassing the HasTraits metaclass to create a new derivative metaclass, or just subclassing an instance of HasTraits?

For the former, you can look at HasPrivateTraits and HasStrictTraits classes as a pointer.  In the latter case, if you just want to add a "units" trait at the top of your object hierarchy, can't you use normal Python inheritance?

Sorry for the lagged response,

More information about the Scipy-dev mailing list