INNER CODE UNIT · Python
DictDotLookup
netaddr/netaddr · netaddr/core.py:152
class DictDotLookup(object):
"""
Creates objects that behave much like a dictionaries, but allow nested
key access using object '.' (dot) lookups.
Recipe 576586: Dot-style nested lookups over dictionary based data
structures - http://code.activestate.com/recipes/576586/
"""
def __init__(self, d):
for k in d:
if isinstance(d[k], dict):
self.__dict__[k] = DictDotLookup(d[k])
elif isinstance(d[k], (list, tuple)):
l = []
for v in d[k]:
if isinstance(v, dict):