fork(1) download
  1. class A(object):
  2.  
  3. @classmethod
  4. def demo_method(cls, a):
  5. print(a)
  6.  
  7.  
  8. def decorator(function):
  9. from functools import wraps
  10. @wraps(function)
  11. def wrapper(*args, **kwargs):
  12. return_value = function(*args, **kwargs)
  13. return return_value
  14.  
  15. return wrapper
  16.  
  17.  
  18. setattr(A, 'demo_method', decorator(A.demo_method))
  19.  
  20. A.demo_method(1)
  21.  
Success #stdin #stdout 0.02s 27704KB
stdin
Standard input is empty
stdout
1