Skip to content

Instantly share code, notes, and snippets.

@AdamSaleh
Created April 30, 2014 12:06
Show Gist options
  • Select an option

  • Save AdamSaleh/ac5e292ab2ec53091a55 to your computer and use it in GitHub Desktop.

Select an option

Save AdamSaleh/ac5e292ab2ec53091a55 to your computer and use it in GitHub Desktop.
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