Skip to content

Instantly share code, notes, and snippets.

@shomah4a
Created March 21, 2011 10:56
Show Gist options
  • Save shomah4a/879296 to your computer and use it in GitHub Desktop.
Save shomah4a/879296 to your computer and use it in GitHub Desktop.
staticmethod
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