[Tutor] Assigning a variable to an FTP directory listing

Alan Gauld alan.gauld at btinternet.com
Thu Dec 12 01:26:31 CET 2013


On 11/12/13 23:55, Pat Martin wrote:

> ftp=FTP(ftpserver)
> ftp.login(user=username,passwd=password)
> ftp.cwd(remoteworkdir)
> listoffiles = ftp.retrlines('NLST')
> print listoffiles
> ftp.quit()
>
> The output I get is:
>
> sampleone
> samplethree
> sampletwo
> 226 Directory send OK.
>
> The list of files I get is just from running the ftp.retrlines command
> it isn't because of the variable printing. If I do it without the
> assignment of the listoffiles variable it just lists the files from
> running that command and the Directory send OK isn't there.

Any chance its coming from the ftp.quit?

try adding a print '---------' before calling ftp.quit...

Just a random guess!


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list