Terry Reedy wrote:

> 
> "J. David Ibanez" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> 
> Given that the behavior of hasattr is clearly defined in Lib Manual
> 2.1 as equivalent to
> 
> def hasattr(obj, name):
>   try:
>     getattr(obj, name)
>     return True
>   except:
>    return False
> 
> I am not sure what could be confusing about it.  It is a simple
> getattr wrapper converting 'got something' to True and 'did not get
> anything' (raised an exception instead) to False.  Users should know
> this so they don't wastefully write 'if hasattr(o,n): x =
> getattr(o,n)'

See also http://python.org/sf/504714

Just
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to