Get error message from FTPLib

Jeff McNeil jeff at
Wed Sep 23 20:55:43 CEST 2009

On Sep 23, 1:46 pm, Bakes <ba... at> wrote:
> I am using ftplib for a project, using a try/except loop.
> I would like to find out the exception, but I am a python newbie and
> do not know how.
> How, in a try/except loop would I find the ftplib exception?

For a bit on exception handling in general, check out the section
within the Python tutorial:
As far as the ftplib module goes, it has an attribute named
'all_errors.' It's a tuple that contains all of the Exception types
that ftplib.FTP methods will throw. You can do something like the

except ftplib.all_errors, e:

I do something much like that in an NMS-like application I wrote.



More information about the Python-list mailing list