|Hi

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


import urllib2

f1 = urllib2.urlopen('ftp://username:[EMAIL PROTECTED]/data.zip')
f2 = file("data.zip", "wb")

while f1: # When to stop ?
     f2.write(f1.read(1024))

f1.close()
f2.close()

||

I can get the size & use it in a for loop :

||||length = float(f1.info().getheader("Content-Length"))
block = 1024

for i in range(0, int(length/block + 1)):
   s = f1.read(block)
   f2.write(s)|||


But this will not work for a file whose size is not known. So I need to get this done via EOF method.

Thanks
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to