mirror of
https://github.com/python/cpython.git
synced 2025-07-07 19:35:27 +00:00
bpo-45975: Simplify some while-loops with walrus operator (GH-29347)
This commit is contained in:
parent
25bc115df9
commit
024ac542d7
28 changed files with 41 additions and 153 deletions
|
@ -67,10 +67,7 @@ def encode(input, output, quotetabs, header=False):
|
|||
output.write(s + lineEnd)
|
||||
|
||||
prevline = None
|
||||
while 1:
|
||||
line = input.readline()
|
||||
if not line:
|
||||
break
|
||||
while line := input.readline():
|
||||
outline = []
|
||||
# Strip off any readline induced trailing newline
|
||||
stripped = b''
|
||||
|
@ -126,9 +123,7 @@ def decode(input, output, header=False):
|
|||
return
|
||||
|
||||
new = b''
|
||||
while 1:
|
||||
line = input.readline()
|
||||
if not line: break
|
||||
while line := input.readline():
|
||||
i, n = 0, len(line)
|
||||
if n > 0 and line[n-1:n] == b'\n':
|
||||
partial = 0; n = n-1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue