# What is @ operator in Python?

PythonServer Side ProgrammingProgramming

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### Practical Machine Learning using Python

Best Seller

91 Lectures 23.5 hours

#### Practical Data Science using Python

22 Lectures 6 hours

@ symbol is used to define decorator in Python. Decorators provide a simple syntax for calling higher-order functions. By definition, a decorator is a function that takes another function and extends the behavior of the latter function without explicitly modifying it.

we have two different kinds of decorators in Python:

• Function decorators
• Class decorators

A decorator in Python is any callable Python object that is used to modify a function or a class. A reference to a function  or a class  is passed to a decorator and the decorator returns a modified function or class. The modified functions or classes usually contain calls to the original function.

@decorator
def f(argument):
….

will replace f by decorator(f): calling f(argument) is then equivalent to decorator(f)(argument).

Updated on 30-Jul-2019 22:30:22