Python FTP - NameError: name 'mydpa' is not defined

Harry laiyijia at yahoo.ca
Mon Jul 28 15:27:31 CEST 2008


Hi there. I am trying to download a file(sn.last) from a public FTP 
server with the following code:

from ftplib import FTP
ftp=FTP('tgftp.nws.noaa.gov')
ftp.login()
ftp.cwd('SL.us008001/DF.of/DC.radar/DS.81dpr/SI.kbuf')
ftp.retrbinar('RETR sn.last', open(mydpa,'wb').write)
ftp.quit()

but got an error message, which I think is normal:

Traceback (most recent call last):
  File "<pyshell#13>", line 1, in <module>
    ftp.retrbinary('RETR sn.last', open(mydpa,'wb').write)
NameError: name 'mydpa' is not defined

I don't know much about python, but just try to use the code to 
download data. I don't know where the file will be saved to. Is the 
mydata a file name or a folder name? where will it be saved to even 
if it's working? Please help be fixed the problem step by step? I am 
using 2.5.2 by the way.

I really appreciate your help. Thanks.





More information about the Python-list mailing list