Skip to content

Instantly share code, notes, and snippets.

@liuyix
Created September 3, 2013 03:58
Show Gist options
  • Select an option

  • Save liuyix/6419586 to your computer and use it in GitHub Desktop.

Select an option

Save liuyix/6419586 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
#-*- encoding:utf-8 -*-
class ClassTest:
FOO = 'foo'
__bar = 'secret!'
def __init__(self, **args):
self.__dict = {}
self.__dict[ClassTest.FOO] = args[ClassTest.FOO]
self.fill_dict(ClassTest.FOO, **args)
def fill_dict(self,key,**args):
self.__dict[key] = args[key]
def printout(self):
print "%s is %s" % (ClassTest.FOO, self.__dict[ClassTest.FOO])
print ClassTest.__bar
if __name__ == "__main__":
d = {ClassTest.FOO:ClassTest.FOO}
test = ClassTest(**d)
test.printout()
print ClassTest.FOO
print ClassTest.__bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment