Created
May 25, 2017 12:38
-
-
Save zeffii/1149ab4edc2778d1931065ab6d50e14f to your computer and use it in GitHub Desktop.
dot lookup for dicts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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