def graceful_get(d, *args):
if not d:<EOL><INDENT>return d<EOL><DEDENT>value = d<EOL>for arg in args:<EOL><INDENT>try:<EOL><INDENT>value = value[arg]<EOL><DEDENT>except (IndexError, KeyError, AttributeError, TypeError) as ex:<EOL><INDENT>logger.debug("<STR_LIT>", ex, str(value)[:<NUM_LIT:32>])<EOL>return None<EOL><DEDENT><DEDENT>return value<EOL>
Obtain values from dicts and lists gracefully. Example:

::

    print(graceful_get({"a": [{1: 2}, {"b": "c"}]}, "a", "b"))
    c

:param d: collection (usually a dict or list)
:param args: list of keys which are used as a lookup
:return: the value from your collection