Guilhem Faure wrote:
usually called "at sign" in english.
in your example, "f1(arg)" and "f2" are decorators. the above is
equivalent to writing
def func():
pass
func = f1(arg)(f2(func ))
that is, define a function, and then pass it to the function "f2", and
then to the function that's returned by calling "f1(arg)". the final
value of the "func" variable is whatever the decorators returned.
the decorator functions (f2 and whatever f1(arg) returns) can manipulate
the function being defined, or even replace it with something else.
specification:
some (semi-advanced) articles:
</F>
What means @ in python ?
In this script for exemple (this script return an error in my konsole...)
>
@f1(arg)
@f2
def func(): pass
>
I see several script where used this symbol but I can't understand.
>
@f1(arg)
@f2
def func(): pass
>
I see several script where used this symbol but I can't understand.
equivalent to writing
def func():
pass
func = f1(arg)(f2(func ))
that is, define a function, and then pass it to the function "f2", and
then to the function that's returned by calling "f1(arg)". the final
value of the "func" variable is whatever the decorators returned.
the decorator functions (f2 and whatever f1(arg) returns) can manipulate
the function being defined, or even replace it with something else.
specification:
some (semi-advanced) articles:
</F>