[Python-Dev] Assignment expression and coding style: the while True case (original) (raw)

Serhiy Storchaka storchaka at gmail.com
Thu Jul 5 02:23:34 EDT 2018


05.07.18 01:51, Victor Stinner пише:

== Pattern 1, straighforward ==

while True: line = input.readline() if not line: break ... IMHO here assingment expression is appropriate here. The code remains straighfoward to read. while (line := input.readline()): ...

We already have an idiom for this:

for line in input: ...



More information about the Python-Dev mailing list