Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created May 25, 2017 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/1149ab4edc2778d1931065ab6d50e14f to your computer and use it in GitHub Desktop.
Save zeffii/1149ab4edc2778d1931065ab6d50e14f to your computer and use it in GitHub Desktop.
dot lookup for dicts
class attrDict(dict):
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
gip = attrDict({'wonder': 20, 'woman': 10})
print(gip.wonder)
print(gip.woman)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment