Guest User

Untitled

a guest
Dec 14th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. def log_decorator():
  2. def log_real_decorator(f):
  3. @wraps(f)
  4. def wrapper(self,*args, **kw):
  5. print "I am the decorator, I know that self is", self, "and I can do whatever I want with it!"
  6. print "I also got other args:", args, kw
  7. f(*args, **kw)
  8.  
  9. return wrapper
  10. return log_real_decorator
  11.  
  12. class Foo(object):
  13. @log_decorator
  14.  
  15. def meth(self):
  16. print "I am the method, my self is", self
  17.  
  18.  
  19. f = Foo()
  20. f.meth()
Add Comment
Please, Sign In to add comment