Decorator is the concept in a program which takes a function, adds some functionality and returns it.
Program to illustrate the working of decorators
def decorate(fun): def newfun(): print("Start") fun() print("Stop") return newfun @decorate def work(): print("I am Working") work()
Output:
Start I am Working Stop
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Program to illustrate the working of decorators
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer