Created
April 30, 2014 12:06
-
-
Save AdamSaleh/ac5e292ab2ec53091a55 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
| In [1]: class Test(object): | |
| ...: password = "asdf" | |
| ...: @classmethod | |
| ...: def printPass(cls): | |
| ...: print cls.password | |
| ...: @classmethod | |
| ...: def printAsdf(cls): | |
| ...: print "asdf" | |
| ...: | |
| In [2]: Test.printPass() | |
| asdf | |
| In [3]: Test.print | |
| Test.printAsdf Test.printPass | |
| In [5]: def classWNewPass(oldcls,newpass): | |
| ...: class NewTestCls(oldcls): | |
| ...: password = newpass | |
| ...: return NewTestCls | |
| ...: | |
| In [6]: NTest = classWNewPass(Test,"jklo") | |
| In [8]: Test.printPass() | |
| asdf | |
| In [9]: NTest.printPass() | |
| jklo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment