Skip to content

Instantly share code, notes, and snippets.

@schipiga
Last active October 28, 2016 19:31
Show Gist options
  • Save schipiga/0671f835e1ab91cf77d4 to your computer and use it in GitHub Desktop.
Save schipiga/0671f835e1ab91cf77d4 to your computer and use it in GitHub Desktop.
import types
class ClassMethod(object):
def __init__(self, func):
self.__func__ = func
def __get__(self, obj, objtype=None):
return types.MethodType(self.__func__, objtype or type(obj), type)
def class_method(func):
return ClassMethod(func)
class StaticMethod(object):
def __init__(self, func):
self.__func__ = func
def __get__(self, obj, objtype=None):
return self.__func__
def static_method(func):
return StaticMethod(func)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment