Created
September 3, 2013 03:58
-
-
Save liuyix/6419586 to your computer and use it in GitHub Desktop.
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
| #!/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