If I had a dictionary dict and I wanted to check for dict[\'key\'] I could either do so in a try block (bleh!) or use the get()<
dict
dict[\'key\']
try
get()<
A more direct analogue to dict.get(key, default) than hasattr is getattr.
dict.get(key, default)
hasattr
getattr
val = getattr(obj, 'attr_to_check', default_value)
(Where default_value is optional, raising an exception on no attribute if not found.)
default_value
For your example, you would pass False.
False