[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
- Previous message (by thread): [Python-Dev] Assignment expression and coding style: the while True case
- Next message (by thread): [Python-Dev] Assignment expression and coding style: the while True case
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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: ...
- Previous message (by thread): [Python-Dev] Assignment expression and coding style: the while True case
- Next message (by thread): [Python-Dev] Assignment expression and coding style: the while True case
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]