Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. def foo(func):
  2.     def wrapper(*args, **kwargs)
  3.         print('I am a decorator')
  4.         return func(*args, **kwargs)
  5.     return wrapper
  6.  
  7. @foo
  8. def bar():
  9.     print('woo! my decorator called me')
  10.  
  11. ## this could be accomplished like this as well: foo(bar). the @ operator is what tells python to pass bar into foo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement