I'm afraid there isn't. The way to do it would be with try...except
, like this:
try:
value = dictionary['key_parent']['key_child']['key_grandchild']
except KeyError:
# no key
or multiple nested if
:
value = None
if 'key_parent' in dictionary:
if 'key_child' in dictionary['key_parent']:
if 'key_grandchild' in dictionary['key_parent']['key_child']:
value = dictionary['key_parent']['key_child']['key_grandchild']