EOF
Anjanesh Lekshminarayanan
mail at anjanesh.net
Sun Aug 24 13:48:12 EDT 2008
Thanks for the shutil.copyfileobj.
Oddly, the EOFError didnt work though.
Gabriel Genellina wrote:
> En Fri, 22 Aug 2008 16:53:58 -0300, Wojtek Walczak <gminick at bzt.bzt> escribió:
>
>
>> On Fri, 22 Aug 2008 22:18:37 +0530, Anjanesh Lekshminarayanan wrote:
>>
>>
>>> Im trying to download a file from a server. But how do I detect EOF ?
>>>
>> Whenever read() method returns empty string/list.
>>
>>
>>
>>> while f1: # When to stop ?
>>>
>> retval = f1.read()
>> if not retval:
>> break
>> f2.write(retval)
>>
>
> Those read() should be read(size) - read() tries to get the whole contents in memory.
> Anyway, shutil.copyfileobj already implements that logic.
>
>
More information about the Python-list
mailing list