Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # b_decorator.py
- def mydecorator(decorated_func):
- def wrapped(*args, **kwargs):
- print("In decorator!")
- return decorated_func(*args, **kwargs)
- return wrapped
- @mydecorator
- def myfunc(myarg):
- print("In decorated myfunc function", myarg)
- def my2nd_func(myarg):
- print("In my2nd_func function", myarg)
- myfunc('global string')
- my2nd_func('my2nd_func without decorator')
- my2nd_func = mydecorator(my2nd_func)
- my2nd_func('my2nd_func with decorator added')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement