

def dunder_get(_dict, key):
    'Returns value for a specified dunderkey\n\n    A "dunderkey" is just a fieldname that may or may not contain\n    double underscores (dunderscores!) for referrencing nested keys in\n    a dict. eg::\n\n         >>> data = {\'a\': {\'b\': 1}}\n         >>> nesget(data, \'a__b\')\n         1\n\n    key \'b\' can be referrenced as \'a__b\'\n\n    :param _dict : (dict)\n    :param key   : (str) that represents a first level or nested key in the dict\n    :rtype       : (mixed) value corresponding to the key\n\n    '
    parts = key.split('__', 1)
    try:
        result = _dict[parts[0]]
    except KeyError:
        return None
    else:
        return (result if (len(parts) == 1) else dunder_get(result, parts[1]))

dataset/ETHPy150Open naiquevin/lookupy/lookupy/dunderkey.py dunder_get/original