[Python-Dev] Examples for PEP 572

Chris Angelico rosuav at gmail.com
Tue Jul 3 17:51:26 EDT 2018


On Wed, Jul 4, 2018 at 7:37 AM, Serhiy Storchaka <storchaka at gmail.com> wrote:
> I believe most Python users are not
> professional programmers -- they are sysadmins, scientists, hobbyists and
> kids --

[citation needed]

> In particularly mutating and
> non-mutating operations are separated. The assignment expression breaks
> this.

[citation needed]

In terms of blending mutating and non-mutating operations, augmented
assignment is far worse. Contrast:

>>> x = 1
>>> y = x
>>> x += 1

>>> a = [1]
>>> b = a
>>> a += [2]


Assignment expressions do the exact same thing as assignment
statements, but also allow you to keep using that value. There is
nothing about mutation. (Unless you believe that assignment *itself*
is mutation, in which case Python is definitely the wrong language for
you.)

ChrisA


More information about the Python-Dev mailing list