ftplib and retrbinary or retrlines (losing newline characters in my log files)

Gabriel Genellina gagsl-py at yahoo.com.ar
Mon Jan 29 00:23:26 CET 2007

At Friday 26/1/2007 09:47, aus stuff wrote:

>Hi, im not sure if this is how i reply to the mail-list, excuse me 
>if incorrect.

Forwarding now to the list.

>Gabriels' solution works fine  > ftp.retrlines('RETR ' + fl, lambda 
>line:fileObj.write('%s\n' % line))
>But lambda's confuse me (newbie here) how could i do the same with a 
>normal function?

lambda args: whatever

is the same as:

def anonymous_function(args):
     return whatever

So, the above example could be written as:

def writeline(line):
     fileObj.write('%s\n' % line)
ftp.retrlines('RETR ' + fl, writeline)

(the write method has no return value, so we omit the return statement)

Gabriel Genellina
Softlab SRL 


Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 

More information about the Python-list mailing list