What is ( @ ) symbol in python.

frohbwzq report abuse

I am relatively new to python and noticed that some functions have some kind of annotation before them, like "@requires_auth". How do they work?

Answers

hugh-enxing report abuse

Those are called decorators.

Comments
LeoG report abuse
Interesting link
uxdyx report abuse

These are called decorators, not annotations.Essentially they are functions that take other functions as arguments. You can read more about them here https://realpython.com/primer-on-python-decorators/

herVi853 report abuse

"@" decorators are used when you need to "wrap"(to add something) function without changing its functional. Decorators are commonly used to track time, log variables before and after functions or validation of the arguments. In case of "@requires_auth", it checks the authentication header of an incoming request.

Comments
LeoG report abuse
Helpful, thx.
Add Answer

Need support?

Just drop us an email to ... Show more