What is ( @ ) symbol in python.
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?
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?
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/
"@" 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.
Just drop us an email to ... Show more