[Zope] getattr() vs. hasattr()

Chris Withers chrisw@nipltd.com
Thu, 12 Apr 2001 16:14:14 +0100


RTF (Python) M ;-)

- getattr(obj,name,default)

This returned the attribute of obj whose name is stored in 'name'. If an
attribute of that name doesn't exist, the default will be returned.

- hasattr(obj,name)

This returns true if obj has an attribute with the name stored in name.
It returned false if obj has no attribute of the specified name...

They are two quite different things...

cheers,

Chris