RETR wants just the remote path name, not a URL. Similarly, you cannot open
a URL; you need to pass it a valid local filename.
Changing it to filename = 'news_2014.txt'
should fix this problem trivially.
The retrlines
method retrieves the lines and optionally performs a callback. You have specified a callback to open a local file for writing, but that's hardly something you want to do for each retrieved line. Try this instead:
textlines = []
ftp.retrlines('RETR ' + filename, textlines.append)
then display the contents of textlines
. (Notice the space between the RETR
command and its argument, too.)
I would argue that the example in the documentation is confusing for a newcomer. Someone should file a bug report.