[Python-ideas] Extending the usage of the @ decoration operator.

MRAB python at mrabarnett.plus.com
Sat May 17 04:08:31 CEST 2014


On 2014-05-17 02:40, Chris B wrote:
> Right now, one can use the @ symbol only for decorations and only bofore
> function or class definition. ("A decorator is just a callable that
> takes a function as an argument and returns a replacement function.").
>
> @dec1(arg)
> @dec2
> def func(): pass
>
>
> If a function has already been defined, it cannot be decorated using the
> decoration operator. But it can still be decorated by explicitly calling
> the decorator:
>
> @dec1(arg)
> @dec2
> def func(): pass
>
> is equivalent to:
>
> def func(): pass
> func = dec1(arg)(dec2(func))
>
>
> Now I propose that the @ symbol should also be usable as an assignment
> operator, in which case a succeeding function definition would not be
> decorated:
>
[snip]
There is a proposal to use @ as an operator for matrix multiplication:

http://legacy.python.org/dev/peps/pep-0465/



More information about the Python-ideas mailing list