[Python-ideas] Spelling of Assignment Expressions PEP 572 (was post #4)

Mikhail V mikhailwas at gmail.com
Sun Apr 15 16:28:28 EDT 2018


On Sun, Apr 15, 2018 at 2:01 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On 15 April 2018 at 19:41, Mikhail V <mikhailwas at gmail.com> wrote:
>> So IIUC, the *only* reason is to avoid '==' ad '=' similarity?
>> If so, then it does not sound convincing at all.
>> Of course Python does me a favor showing an error,
>> when I make a typo like this:
>> if (x = y)
>>
>> But still, if this is the only real reason, it is not convincing.
>
> It's thoroughly convincing, because we're already familiar with the
> consequences of folks confusing "=" and "==" when writing C & C++
> code. It's an eternal bug magnet, so it's not a design we're ever
> going to port over to Python.
[...]
> The examples in the PEP have been updated to better reflect some of
> the key motivating use cases (embedded assignments in if and while
> statement conditions, generator expressions, and container
> comprehensions)

Im personally "0" on the whole proposal. Just was curious
about that "demonisation" of "=" and "==" visual similarity.
Granted, writing ":=" instead of "=" helps a little bit.
But if the ":=" will be accepted, then
we end up with two spellings :-)

>
>> And as a side note: I personally find the look of ":=" a bit 'noisy'.
>
> You're not alone in that, which is one of the reasons finding a
> keyword based option that's less syntactically ambiguous than "as"
> could be an attractive alternative.
>

Keyword variants look less appealing than ":=".
but if it had to be a keyword, then I'd definitely stay by
"TARGET keyword EXPR" just not to swap the traditional order.



Mikhail


More information about the Python-ideas mailing list