[Tutor] Getting a List of FTP Dirs?
Jörg Wölke
lumbricus@gmx.net
Sun, 4 Mar 2001 01:20:08 +0100 (MET)
>
> How about this instead. If I use the dir() method from ftplib, I'll get
> something like this returned:
>
> drwxrwx--- 55 restback privftp 1536 Feb 26 19:19 seattle
> drwxrwx--- 222 restback privftp 4608 Feb 23 15:14 sf
> drwxrwx--- 3 restback privftp 512 Nov 24 10:33 slc
> drwxrwx--- 2 restback privftp 512 Jan 11 08:08 tallships
>
> If I can convert this into a string, I can then work with it and write
> code
> to tell my program that the last word on each line is a directory.
> Unfortunately, I can't seem to get Python to convert this into a string!
> Trying something like:
>
> directories = ftp.dir()
>
> just causes the ftp.dir() code to be executed. Even if I try to explicitly
>
> cast it as a string by doing:
>
> directories = str(ftp.dir())
>
> doesn't seem to work. Any idea on how to get this to work?
>
> Thanks for the help, btw! I'm sure I'm going to be using the os.* modules
> soon enough.
>
> Britt
>
Yo ---
the dox of ftplib (RTFM) sez that the dir() method returns NONE
so you can't cast None to string.
but if the last argument to dir() is a function this function is
used as a callback (f.e. retrlines() *wink*).
this is taken with a grain of salt cuz i didn't check out
ftplib myself.
hope this helps
grrrrretz Jö!
--
Sent through GMX FreeMail - http://www.gmx.net