[Python-ideas] x )= f as shorthand for x=f(x)

Boris Borcic bborcic at gmail.com
Fri Nov 9 18:51:35 CET 2007


Fredrik Johansson wrote:
> On Nov 9, 2007 3:39 PM, Boris Borcic <bborcic at gmail.com> wrote:
>> Title says it all. Got used to += et al. My mind often expects augmented
>> assignment syntax to exist uniformly for whatever transform.
>>
>> If I am not mistaken, python syntax doesn't permit augmented assignment
>> operators to sit between parens so that )= wouldn't risk confusing quick
>> machine- or eye-scans to match parens.
> 
> Would the statement
> 
> ( x )= f
> 
> represent the ordinary assignment x=f or would it become a syntax error?

Ah, and what about

(x,y)=f

- more likely to already exist in the wild, isn't it ?

Well, if ')=' was an augmented assignment operator,
I'd say

(x,y)=f

should parse as a destructuring assignment as it already does
while

(x)=f

should become a syntax error. I admit it's debatable, of course. I think a case 
could be made in terms of lookahead tokens in favor of that solution (all other 
things equal).

Cheers, BB




More information about the Python-ideas mailing list