Doc: fix example for iter() function. (GH-11959)

read() returns bytes for a file opened in binary mode,
so b'' should be used as a sentinel instead of ''.
Otherwise the loop will be infinite.
This commit is contained in:
Cristian Ciupitu 2019-02-21 09:53:06 +02:00 committed by Serhiy Storchaka
parent ebc793d6ac
commit 11fa0e48a9
1 changed files with 1 additions and 1 deletions

View File

@ -816,7 +816,7 @@ are always available. They are listed here in alphabetical order.
from functools import partial
with open('mydata.db', 'rb') as f:
for block in iter(partial(f.read, 64), ''):
for block in iter(partial(f.read, 64), b''):
process_block(block)