Created
March 21, 2017 09:17
-
-
Save vadimkantorov/a67e78a7271f48b41707c6c05e4fd295 to your computer and use it in GitHub Desktop.
AttrDict in one Python line
This file contains hidden or 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
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