Why not "list = ftplib.FTP.dir()" ?

Ian Kelly ian.g.kelly at gmail.com
Mon Feb 7 23:48:51 CET 2011


On Mon, Feb 7, 2011 at 3:26 PM, trylks <trylks at gmail.com> wrote:
> I don't know if it is ftplib or just me, but something feels terribly wrong
> in this:
>
>> from ftplib import FTP
>> from functools import partial
>>
>> class MyFTP(FTP):
>>   def dir(self):
>>     l = []
>>     super(MyFTP, self).dir(partial(lambda l, e: l.append(e.split()), l))
>>     return l

No need to use partial here.  You can simplify that to:

super(MyFTP, self).dir(lambda e: l.append(e.split()))



More information about the Python-list mailing list