Google News
logo
Python - Interview Questions
What is the Python decorator?
Decorators are very powerful and a useful tool in Python that allows the programmers to modify the behaviour of any class or function. It allows us to wrap another function to extend the behaviour of the wrapped function, without permanently modifying it.
 
# Decorator example  
def decoratorfun():  
    return another_fun  
 
Functions vs. Decorators : A function is a block of code that performs a specific task whereas a decorator is a function that modifies other functions.
Advertisement