ftplib callbacks

Matija Papec mpapec at yahoo.com
Sun Nov 21 17:14:07 EST 2004


X-Ftn-To: Steve Holden 

Steve Holden <steve at holdenweb.com> wrote:
>The callback is called each time the FTP client softwrae has something 
>to deal with. Try (untested):
>
>lines = []
>
>def myfilter(line):
>     global lines
>     lines.append(line)
>
>with the remainder of your code unchanged. The lines list will then 
>contain a list of all lines.

Tnx, I did

    def nlst2(self, *args):
        cmd = 'LIST'
        for arg in args:
            cmd = cmd + (' ' + arg)
        files = []
        self.retrlines(cmd, files.append)
        return files

and now I just need to parse it. :)

>The problem with your current callback is that its return value is 
>ignored by the FTP module that calls it.

Yes, unfortunately even "def retrlines" returns something uninteresting.



-- 
Matija



More information about the Python-list mailing list