The ' @ ' symbol used as a function modifier is a new addition to python2.4, and the modifier must appear on the previous line of the function definition and is not allowed on the same line as the function definition. That is to say @a def f (): is illegal. Functions can be decorated only within a module or class definition layer, and no modification of a class is allowed. A modifier is a function that makes the modified function a parameter and returns a modified function with the same name or other callable object.
For example:
def test02 (a): Print ' test02 ' @test02 def Test (A, b ):print'test ' print a+b
Results:
There are many explanations in the official Python documentation, but the code is very clear.
' @dec2 @dec1 def func (arg1, Arg2, ...): Pass is equivalent to:def func (arg1, Arg2, ...): Pass = dec2 (DEC1 (func))
The Python @property property allows you to access the defined function as a property, providing a more friendly way to access it.
The function of the @ modifier in Python.