Source Code:
(back to article)
class MyClass: my_variable = 'some value' obj = MyClass() if hasattr(obj, 'my_variable'): print('obj has my_variable attribute') else: print('obj does not have my_variable attribute')
Result:
Report an issue