

def dunder_truncate(_dict):
    "Returns dict with dunder keys truncated to only the last part\n\n    In other words, replaces the dunder keys with just last part of\n    it. In case many identical last parts are encountered, they are\n    not truncated further\n\n    eg::\n\n        >>> dunder_truncate({'a__p': 3, 'b__c': 'no'})\n        {'c': 'no', 'p': 3}\n        >>> dunder_truncate({'a__p': 'yay', 'b__p': 'no', 'c__z': 'dunno'})\n        {'a__p': 'yay', 'b__p': 'no', 'z': 'dunno'}\n\n    :param _dict : (dict) to flatten\n    :rtype       : (dict) flattened result\n\n    "
    keylist = list(_dict.keys())

    def decide_key(k, klist):
        newkey = dunder_last(k)
        return (newkey if (list(map(dunder_last, klist)).count(newkey) == 1) else k)
    original_keys = [decide_key(key, keylist) for key in keylist]
    return dict(zip(original_keys, _dict.values()))

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