python hasattribute code example
Example 1: hasattr in python
The hasattr() function returns True if the specified object has the specified attribute, otherwise False .
Example 2: python3 check if object has attribute
try:
doStuff(a.property)
except AttributeError:
otherStuff()
Example 3: python hasattribute
hasattr(object, name)