EOF
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Sun Aug 24 06:32:47 EDT 2008
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.
--
Gabriel Genellina
More information about the Python-list
mailing list