Q:

Python program to illustrate the working of decorators

belongs to collection: Python class & object programs

0

Decorator is the concept in a program which takes a function, adds some functionality and returns it.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python class & object programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python program to pass objects as arguments and re... >>
<< Python program to illustrate the working of abstra...