Created
March 21, 2011 10:56
-
-
Save shomah4a/879296 to your computer and use it in GitHub Desktop.
staticmethod
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 StaticMethod(object): | |
def __init__(self, f): | |
self.function = f | |
def __get__(self, *args, **argd): | |
return self.function | |
class Test(object): | |
@StaticMethod | |
def testmethod(a, b): | |
return a+b | |
t = Test() | |
print t.testmethod(10, 20) | |
print Test.testmethod(10, 20) | |
print t.testmethod | |
print Test.testmethod | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment