Source Code:
(back to article)
value = getattr(obj, 'attr', 0) print(value) # prints 1 value = getattr(obj, 'other_attr', 0) print(value) # prints 0
Result:
Report an issue