__getattr__, hasattr
Fredrik Lundh
fredrik at pythonware.com
Tue Dec 14 09:21:02 EST 1999
Ionel Simionescu <ionel at psy.uva.nl> wrote:
> It seems that since one defines __getattr__,
> hasattr(obj, name) will happily answer 'yes' irrespective of the attribute
> name.
only if you define a __getattr__ that always
succeeds...
> This does not appear very sound to me.
why not? if __getattr__ doesn't complain,
why should hasattr?
> Do I overlook anything?
probably ;-)
see the description of "hasattr" for more info:
http://www.python.org/doc/current/lib/built-in-funcs.html
</F>
<!-- (the eff-bot guide to) the standard python library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->
More information about the Python-list
mailing list