Skip to content

Instantly share code, notes, and snippets.

@vadimkantorov
Created March 21, 2017 09:17
Show Gist options
  • Save vadimkantorov/a67e78a7271f48b41707c6c05e4fd295 to your computer and use it in GitHub Desktop.
Save vadimkantorov/a67e78a7271f48b41707c6c05e4fd295 to your computer and use it in GitHub Desktop.
AttrDict in one Python line
attrdict = type('attrdict', (dict, ), dict(__getattr__ = dict.__getitem__, __setattr__ = dict.__setitem__))
# d = attrdict(a = 1, b = 2)
# print(d.a, d['b'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment