Warning when new attributes are added to classes at run time

jay graves jaywgraves at gmail.com
Wed Jul 19 17:27:05 EDT 2006


Matthew Wilson wrote:
> I sometimes inadvertently create a new attribute on an object rather
> update a value bound to an existing attribute.  For example:
<snippage>
> All comments are welcome.  Is there a better way of implementing the
> above class, OR, is this approach generally wrong-headed?  Am I the only
> one that makes this mistake?

It's never been much a problem for me but you could look into __slots__

http://docs.python.org/ref/slots.html

...
jay




More information about the Python-list mailing list