A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2018-July/154401.html below:

[Python-Dev] PEP 572 semantics: all capabilities of the assignment statement

[Python-Dev] PEP 572 semantics: all capabilities of the assignment statementNick Coghlan 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
577.

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)

Cheers,
Nick.

>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180706/9bc9eed6/attachment.html>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4