python check if class has property code example
Example 1: python check if class has function
class A:
def func():
pass
hasattr(A(), 'func')
Example 2: python check if attribute exists in class
if hasattr(obj, 'propertyName'):
...
class A:
def func():
pass
hasattr(A(), 'func')
if hasattr(obj, 'propertyName'):
...