Is there a way in Python to determine if an object has some attribute? For example:
>>> a = SomeClass() >>> a.someProperty = value >>
You can use hasattr() or catch AttributeError, but if you really just want the value of the attribute with a default if it isn't there, the best option is just to use getattr():
hasattr()
AttributeError
getattr(a, 'property', 'default value')