[Python-Dev] PEP 572 semantics: all capabilities of the assignment statement
ncoghlan at gmail.com
Thu Jul 5 18:44:46 EDT 2018
On Thu., 5 Jul. 2018, 3:17 pm Guido van Rossum, <guido at python.org> wrote:
> Let me be slightly contrarian. :-)
> On Wed, Jul 4, 2018 at 9:12 PM Chris Angelico <rosuav at gmail.com> wrote:
>> Definitely against augmentation, for several reasons:
>> 1) Spelling - should it be :+= or +:= ?
> That one's easy. As Nick's (withdrawn) PEP 577 shows it should be simply
>> 2) Is the result of the expression the modified value or the original?
> Someone (sadly I forget who) showed, convincingly (to me anyways :-) that
> it should return whatever the `__iadd__` method returns, or (if there isn't
> one) the result of `a = a + b`.
I think I had it as an open question in one of the earlier drafts of PEP
The subsequent rationale for it returning the modified value was that we
have this existing equivalence at the statement level:
a += b
a = operator.iadd(a, b)
So the natural expression level semantics would be:
a := operator.iadd(a, b)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev