hasattr + __getattr__: I think this is Python bug

Christian Heimes lists at cheimes.de
Tue Jul 20 08:40:18 EDT 2010


Am 20.07.2010 12:10, schrieb dmitrey:
> hi all,
> I have a class (FuncDesigner oofun) that has no attribute "size", but
> it is overloaded in __getattr__, so if someone invokes
> "myObject.size", it is generated (as another oofun) and connected to
> myObject as attribute.

How about using a property instead of the __getattr__() hook? A property
is a computed attribute that (among other things) plays much nicer with
hasattr.




More information about the Python-list mailing list