ivapopova

simple_decorator_with_parameter.py

Mar 30th, 2018
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.23 KB | None | 0 0
  1. def stars_decorator(f):
  2.     def wrapper(n):
  3.         print("*" * 50)
  4.         f(n)
  5.         print("*" * 50)
  6.  
  7.     return wrapper
  8.  
  9. # let's decorate greet:
  10. @stars_decorator
  11. def greet(name):
  12.     print("Howdy {}!".format(name))
  13.  
  14.  
  15. # and use it:
  16. greet("Pesho")
Advertisement
Add Comment
Please, Sign In to add comment