标签:tool art pre eth cto too tools __init__ from
实现 classmethod装饰器from functools import wraps, partial
class Classmethod:
def __init__(self, method):
wraps(method)(self)
def __get__(self, instance, cls):
return partial(self.__wrapped__, cls)
class C:
@Classmethod
def method(cls):
print(cls)
@Classmethod
def method2(cls, x):
print(cls)
print(x)
c =C()
c.method()
c.method2(1)
标签:tool art pre eth cto too tools __init__ from
原文地址:https://blog.51cto.com/14730644/2476069