EOF

Eric Wertman ewertman at gmail.com
Fri Aug 22 18:28:09 EDT 2008


>> Im trying to download a file from a server. But how do I detect EOF ?

Shouldn't this work as well?

f1 = urllib2.urlopen('ftp://username:password@ftp.ftp-server.tld/data.zip')
f2 = file("data.zip", "wb")

while f1: # When to stop ?
    try :
        f2.write(f1.read(1024))
    except EOFError :
        break

f1.close()
f2.close()

Not that it's really any better, if it works...  I'm wondering myself.

Eric



More information about the Python-list mailing list