Skip to content

Instantly share code, notes, and snippets.

@carljm
Created June 27, 2012 14:55
Show Gist options
  • Save carljm/3004616 to your computer and use it in GitHub Desktop.
Save carljm/3004616 to your computer and use it in GitHub Desktop.
pure Python implementation of the staticmethod decorator
class StaticMethod(object):
def __init__(self, func):
self.func = func
def __get__(self, obj, cls):
return self.func
def staticmethod(func):
return StaticMethod(func)
@schipiga
Copy link

@dogewzy, it's Python descriptors protocol, pls see details in https://docs.python.org/3.7/reference/datamodel.html#object.__get__

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment