On Mon, 13 Jun 2005 01:25:51 -0400, "Phillip J. Eby" <[EMAIL PROTECTED]> wrote:
>At 09:01 PM 6/12/2005 -0700, Guido van Rossum wrote:
>>If we have to do this, PEP 315 has my +0.
>>
>>It is Pythonically minimal and the motivation rings true: I've often
>>written code like this in the past:
>>
>> line = f.readline()
>> while line:
>> <do something>
>> line = f.readline()
>>
>>But these days we do that using "for line in f".
>
>Block-copying a file with read() has the same pattern (e.g. in shutil), but
>you can't make it a for loop.
Anything can be a for loop.
for chunk in iter(lambda: f1.read(CHUNK_SIZE), ''):
f2.write(chunk)
Jp
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com