Decorators => provide a way to modify functions using other functions,
>>>
def decor(func):
def wrap(): #nested function
print("==============")
func()
print("==============")
return wrap
def print_text():
print("Hello World")
decorated = decor(print_text)
decorated()
>>>
@my_dec
>>>
my_func = my_dec(my_func)
No comments:
Post a Comment