[Tutor] How to define a callback

"Héctor Villafuerte D." hec.villafuerte at telgua.com.gt
Thu Dec 11 14:07:51 EST 2003


Hi all!

I'm using the ftplib module and need to look for certain
files. I'm planning on using string.find on the output of
LIST. The question is: how to define a callback for the
ftplib function retrlines? i.e. I don't want to print to
sys.stdout, I want to print to a string.


retrlines(command[, callback])
   Retrieve a file or directory listing in ASCII transfer mode.
   command should be an appropriate "RETR" command (see retrbinary())
   or a "LIST" command (usually just the string 'LIST').
   The callback function is called for each line, with the trailing
   CRLF stripped. The default callback prints the line to sys.stdout.


Thanks for your help.





More information about the Tutor mailing list