Domanda

I have a script that is pulling data from a file down from an ftp site using ftplib:

ftp.retrlines('RETR '+weatherfile,callback=handleData)

So I want to define handleData to deal with the data coming down, but I would like to be able to pass in additional args to that function. So far, I haven't been able to figure out how to do this. The callback function is meant to take a single arg. Is there a way to get it to handle more than 1, or is there a reason that I should avoid trying to do it this way?

È stato utile?

Soluzione

How about using lambda?

ftp.retrlines('RETR ' + weatherfile,
              callback=lambda line: handleData(line, other_arg, another_arg))
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top