Using a Callback Function - ftplib

David 71david at libero.it
Mon Aug 17 19:51:33 CEST 2009


Il Mon, 17 Aug 2009 10:43:33 -0700 (PDT), seldan24 ha scritto:

> Hello,
> 
> I'm utterly confused by something which is most likely trivial.  I'm
> attempting to connect to an FTP server, retrieve a list of files, and
> store than in an array.  I.e.:
> 
> import ftplib
> 
> ftp = ftplib.FTP(server)
> ftp.login(user, pass)
> ftp.cwd(conf['testdir'])

Why bother with retrlines? Use the provided higer level fuctions:

remotefiles = []
ftp.dir(remotefiles.append)

or, if you prefer nlst

remotefiles = ftp.nlst()

regards
david



More information about the Python-list mailing list