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

Chris Angelico rosuav at gmail.com
Wed Apr 25 16:24:56 EDT 2018


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.

ChrisA


More information about the Python-Dev mailing list