I want to get the contents of a file with ftplib and store it in a string variable in python. My first attempt is below. I guess lambdas can't contain assignment -- maybe because a lambda is a function + variables that should be self contained (?).
contents = ""
ftp.retrlines("RETR " + filename, lambda s: contents=s) #lambda cannot contain assignment
Anyway, do I need to capture output to stdout or is there an easier way?