[Python-Dev] (name := expression) doesn't fit the narrative of PEP 20

Guido van Rossum guido at python.org
Wed Apr 25 16:28:45 EDT 2018


A very emotional appeal, you don't seem to grasp the usability improvements
this will give. I hear you but at this point appeals to Python's "Zen"
don't help you.

On Wed, Apr 25, 2018 at 1:21 PM, Łukasz Langa <lukasz at langa.pl> wrote:

> PEP 572 caused a strong emotional reaction in me. I wanted to first
> understand
> my intuitive objection to the idea before posting anything.
>
> I feel that (name := expression) doesn't fit the narrative of PEP 20. It
> doesn't remove complexity, it only moves it. What was its own assignment
> before
> now is part of the logic test. This saves on vertical whitespace but makes
> parsing and understanding logic tests harder. This is a bad bargain: logic
> tests already contain a lot of complexity that human readers have to cope
> with.
>
> Proponents of := argue it makes several patterns flatter (= better than
> nested)
> to express. Serial regular expression matching is a popular example.
> However,
> (name := expression) itself is making logic tests more nested, not
> flatter. It
> makes information in the logic test denser (= worse than sparse). Since it
> also
> requires an additional pair of parentheses, it forces the reader to
> decompose
> the expression in their head.
>
> := also goes against having one obvious way to do it. Since it's an
> expression,
> it can also be placed on its own line or in otherwise weird places like
> function call arguments. I anticipate PEP 8 would have to be extended to
> explicitly discourage such abuse. Linters would grow rules against it.
> This is
> noise.
>
> I'm -1 on PEP 572, I think it's very similar in spirit to the rejected PEP
> 463.
>
> -- Ł
>
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/
> guido%40python.org
>
>


-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20180425/23a95029/attachment.html>


More information about the Python-Dev mailing list