[Python-ideas] Assignment decorators (Re: The Descriptor Protocol...)

Larry Hastings larry at hastings.org
Tue Mar 8 20:22:50 CET 2011

On 03/07/2011 10:50 PM, Raymond Hettinger wrote:
> Just for the fun of it, here's my offering:
>      a := gizmo(arg1, arg2)
> is equivalent to
>      a = gimzo(arg1, arg2, __name__='a')

How do you call two assignment decorators with this syntax?

> Advantages:
>    * Keep the current '@' notation unambiguous

I don't think any of the proposed annotation syntaxes have been ambiguous.

>    * The program still looks like a Python program

A debatable matter of taste.  For better or worse, decorators in Python 
use '@'--that ship has sailed.  I suggest adding a second new 
never-before-seen syntax just for assignment decoration seems less 
Pythonic to me than reusing '@' in a new context.

> Disadvantage:
>    * I'm still not sure that the "problem" is worth solving.

Hear hear!  Certainly all the proposals so far have struck me being as 
worse than the problem.  Including mine!

I'd be very interested in someone demonstrating a killer app for this 
hypothetical feature,


More information about the Python-ideas mailing list