why is this invalid b = a += b ?
tjreedy at udel.edu
Sun Jan 25 01:11:03 CET 2009
Stef Mientki wrote:
> I can assign a value to more than 1 variable (name) in one line:
> a = b = 3
> So evaluation of this line must start at the right part.
> But the following is not allowed:
> b = 2
> a = b += 1
This strikes me as slightly incoherent. Given that v op=exp is mostly
that same as v = v op exp, I suppose you expect a = b += 1 to be mostly
the same as a = b = b+1, but what would you do with a += b = 1, or even
a *= b += 1. There is some virtur to restricting augmented assignment
to one target and one delimiter. Even that seems to cause some trouble.
More information about the Python-list