Why not a, b += i, j? (augmented assignment via tuple unpacking)
Steven Rumbalski
srumbalski at prodigy.net
Wed Nov 27 01:24:08 EST 2002
Grant Edwards wrote:
> In article <KbRE9.534$RQ3.26615908 at newssvr17.news.prodigy.com>, Steven
> Rumbalski wrote:
>
>> In python I can write:
>>
>> a, b = i, j
>>
>> but the following is not legal:
>>
>> a, b += i, j
>>
>> Is there a reason that allowing this would be bad?
>
> If it were allowed, what do you propose it would do?
>
>> Why does Python forbid this?
>
> First tell us what you think it would do were it legal. :)
>
I was imagining it working like
>>> a += i
>>> b += j
I suppose it could appear that I meant
>>> a, b = (a, b) + (i, J)
The first is intuitive to me because of how the following behaves
>>> a, b = i, j
but I guess it's not intuitive to others.
By the way, I did not ask the above question because I thought that Python
was wrong, but because I want to understand the language better.
Steven Rumbalski
More information about the Python-list
mailing list