Use with open() to ensure the file gets close()d
`process_data()`is an undefined name in this context
This commit is contained in:
@@ -22,11 +22,10 @@ def reader2(s, size):
|
||||
|
||||
def iterate_while():
|
||||
CHUNKSIZE = 8192
|
||||
f = open('/etc/passwd')
|
||||
for chunk in iter(lambda: f.read(10), ''):
|
||||
n = sys.stdout.write(chunk)
|
||||
with open('/etc/passwd') as f:
|
||||
for chunk in iter(lambda: f.read(10), ''):
|
||||
n = sys.stdout.write(chunk)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
iterate_while()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user