Lawrence Oluyede wrote:
> "eels" <[EMAIL PROTECTED]> writes:
> 
> 
>>With yyy = ftp.retrlines('LIST') I get this listing at stdout, but I
>>need this information at variable yyy.
>>How can I resolve this problem?
> 
> 
> As written in the doc retrlines has an optional parameter (a callback 
> function)
> called on each line retrieved, so you can do something like this:
> 
> from ftplib import FTP
> 
> def writeline(data):
>     fd.write(data + "\n")
> 
> f = FTP('ftp.kernel.org')
> f.login()
> 
> f.cwd('/pub/linux/kernel')
> fd = open('README', 'wt')
> f.retrlines('RETR README', writeline)
> fd.close()
> f.quit()

How about a little more portability?

def writeline(data):
     fd.write(data + os.linesep)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to