[Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)
Chris Angelico
rosuav at gmail.com
Sun Apr 15 16:28:15 EDT 2018
On Mon, Apr 16, 2018 at 3:19 AM, Guido van Rossum <guido at python.org> wrote:
> On Sun, Apr 15, 2018 at 4:05 AM, Kirill Balunov <kirillbalunov at gmail.com>
> wrote:
>> But somehow this PEP does not mean it! And with the current rationale of
>> this PEP it's a huge CON for me that `=` and `:=` feel and look the same.
>
> Then maybe the PEP needs to be updated.
I can never be sure what people are reading when they say "current"
with PEPs like this. The text gets updated fairly frequently. As of
time of posting, here's the rationale:
-----
Naming the result of an expression is an important part of programming,
allowing a descriptive name to be used in place of a longer expression,
and permitting reuse. Currently, this feature is available only in
statement form, making it unavailable in list comprehensions and other
expression contexts. Merely introducing a way to assign as an expression
would create bizarre edge cases around comprehensions, though, and to avoid
the worst of the confusions, we change the definition of comprehensions,
causing some edge cases to be interpreted differently, but maintaining the
existing behaviour in the majority of situations.
-----
Kirill, is this what you read, and if so, how does that make ':=' a
negative? The rationale says "hey, see this really good thing you can
do as a statement? Let's do it as an expression too", so the parallel
should be a good thing.
ChrisA
More information about the Python-ideas
mailing list