Created
May 5, 2011 23:49
-
-
Save slpsys/958211 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 Stuff: | |
dict = {} | |
def __getattr__(self, key): | |
if not key: | |
return self | |
elif self.dict.has_key(key): | |
return self.dict[key] | |
raise AttributeError,key | |
def __setitem__(self, key, value): | |
self.dict[key] = value | |
def __init__(self, *args, **arg_dict): | |
for k, v in arg_dict.iteritems(): | |
self.dict[k] = v | |
stuff = Stuff(a=1, b=2, c=3) | |
print stuff.b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment