Created
January 24, 2016 05:43
-
-
Save hannal/d45d8dedfd3c15d6d524 to your computer and use it in GitHub Desktop.
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 LikeDict(dict): | |
def __getattribute__(self, attr): | |
return self[attr] | |
def __setattr__(self, attr, value): | |
self[attr] = value | |
class LikeDict2(object): | |
def __getitem__(self, key): | |
return getattr(self, key) | |
def __setitem__(self, key, value): | |
setattr(self, key, value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment