__getattr__, hasattr

Stephen Coursen coursesm at sbdhcp-4024.statenisland-ny.est.tcg.com
Tue Dec 14 08:02:16 EST 1999


On Tue, 14 Dec 1999 13:06:09 +0100, Ionel Simionescu <ionel at psy.uva.nl> wrote:
>Hi,
>
>
>It seems that since one defines __getattr__,
>hasattr(obj, name) will happily answer 'yes' irrespective of the attribute
>name.
>
>This does not appear very sound to me.
>Do I overlook anything?
>
How exactly are you redefining __getattr__ ?  In my redefinitions, I have it
raise an AttributeError if the attribution in question isn't there.  This
causes hasattr to have the appropriate behavior.

Steve

>
>Thanks,
>ionel
>
>



More information about the Python-list mailing list