12 Apr
2001
12 Apr
'01
3:07 p.m.
What's the difference between getattr() and hasattr()? When do you use what? What's the different benefits? Peter
12 Apr
12 Apr
3:14 p.m.
New subject: [Zope] getattr() vs. hasattr()
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
9125
Age (days ago)
9125
Last active (days ago)
1 comments
2 participants
participants (2)
-
Chris Withers -
Peter Bengtsson