Best way to trap errors in ftplib?

Mark McEahern marklists at
Tue Jan 11 19:55:12 EST 2005

Peter A.Schott wrote:

>Using ftplib.FTP object for a project we have here to upload/download files.  I
>know that I can wrap everything in try/except blocks, but I'm having trouble
>getting the exact error messages out of the Exceptions.
Consider using the traceback a la:

    [... whatever ...]
    import sys, traceback
    t, v, tb = sys.exc_info()
    # or use StringIO to "print" the traceback to and then log *that*

// m

More information about the Python-list mailing list