On Tue, Aug 28, 2018 at 6:37 PM Greg Ewing <[email protected]> wrote:
>
> Guido van Rossum wrote:
> > we might propose (as the OP did) that this:
> >
> > a, b, c += x, y, z
> >
> > could be made equivalent to this:
> >
> > a += x
> > b += y
> > c += z
>
> But not without violating the principle that
>
> lhs += rhs
>
> is equivalent to
>
> lhs = lhs.__iadd__(lhs)
(Corrected: lhs = lhs.__iadd__(rhs))
Since lhs here is neither a list nor a tuple, how is it violated? Or
rather, how is it any more of a special case than in this syntax:
# Neither name-binding or setitem/setattr.
[a,b,c] = items
If lhs is a Numpy array, then:
a_b_c += x, y, z
is equivalent to:
a_b_c = a_b_c.__iadd__((x,y,z))
We can translate the original example:
a, b, c += x, y, z
to:
a, b, c = target_list(a,b,c).__iadd__((x,y,z))
where `target_list` is a virtual (not as in "virtual function") type
for target list constructs.
_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/