Why not a, b += i, j? (augmented assignment via tuple unpacking)

Brian Quinlan brian at sweetapp.com
Tue Nov 26 16:28:40 EST 2002


Steven Rumblaski 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?  Why does Python 
> forbid this?

Assignment to a literal doesn't make sense e.g. how is this different
from

(1,2) = (3,4)

But I think that the error message is deceptive, so I've filed a bug
report:

https://sourceforge.net/tracker/index.php?func=detail&aid=644345&group_i
d=5470&atid=105470

Cheers,
Brian





More information about the Python-list mailing list