[Python-Dev] (name := expression) doesn't fit the narrative of PEP 20 (original) (raw)
Łukasz Langa lukasz at langa.pl
Wed Apr 25 17:06:47 EDT 2018
- Previous message (by thread): [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20
- Next message (by thread): [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 25 Apr, 2018, at 1:24 PM, Chris Angelico <rosuav at gmail.com> wrote:
On Thu, Apr 26, 2018 at 6:21 AM, Łukasz Langa <lukasz at langa.pl> wrote: := 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. Does this argument also apply to the if/else expression? Do linters need rules to advise against people writing code like: print(x) if x is None else print(y) ? It's perfectly legal to write code like this. But I don't see people abusing this sort of thing.
Ternary expressions are different because their flow is deliberately different
from a regular if statement. It's also different from the C equivalent.
:=
on the other hand is deciptively similar to =
.
But yeah, I think worrying about abuse of the feature is a red herring. The gist of my criticism of your PEP is about the decreased balance in information density.
-- Ł -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: Message signed with OpenPGP URL: <http://mail.python.org/pipermail/python-dev/attachments/20180425/8b397bea/attachment.sig>
- Previous message (by thread): [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20
- Next message (by thread): [Python-Dev] (name := expression) doesn't fit the narrative of PEP 20
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]