Last active
October 28, 2016 19:31
-
-
Save schipiga/0671f835e1ab91cf77d4 to your computer and use it in GitHub Desktop.
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
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