[Python-ideas] Decorators for variables

Ethan Furman ethan at stoneleaf.us
Fri Apr 1 13:58:09 EDT 2016


On 04/01/2016 10:53 AM, Matthias welp wrote:
>  > But, I think the benefit for @decorator on functions is mainly because a
>  > function body is big, and this way we can read the decorator next to the
>  > function signature while on a variable, this just add another way to
>  > call a function on a variable.
>
> Yes, it is, but I proposed it to give a visual indicator that it does
> not change the value that is assigned to the identifier, but rather
> changes the behaviour of the identifier, just like what most function
> decorators do.

So instead of

   a = Char(length=10, value='empty')

you want

   @Char(length=10)
   a = 'empty'

?

--
~Ethan~



More information about the Python-ideas mailing list