×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python program to illustrate the working of decorators

Here, we are writing a Python program to see how the decorators work?
Submitted by Shivang Yadav, on March 12, 2021

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

Python class & object programs »



Related Programs

Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.