[Python-ideas] x )= f as shorthand for x=f(x)
bborcic at gmail.com
Fri Nov 9 19:00:18 CET 2007
Eduardo O. Padoan wrote:
> On Nov 9, 2007 12: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.
> Bizarre syntax. Close-parens should close something. Also, al it saves
> is 1 char.
Typical motivating usecase is like for other augmented assignment
a[<complex_expression>] += n
saves both the typing and the computation of an <complex_expression>
a[<complex_expression>] += a[<complex_expression>] + n
and an temporary variable assignment over
temp = <complex_expression>
a[<complex_expression>] )= f
a[<complex_expression>] = f(a[<complex_expression>])
etc. More than "just 1 char", anyway.
More information about the Python-ideas