Exception Handling

Joshua Ginsberg listspam at flowtheory.net
Fri Apr 8 17:46:05 EDT 2005


If you use "except:" without any specific error class, it will be a 
catchall for any error class (including Warning and its derivatives). 
Otherwise you can use inheritance to refer to a group of exceptions 
(e.g. "except Exception:" would catch ValueError, since the ValueError 
class inherits from the generic Exception class).

-jag

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Pasted Graphic.tiff
Type: image/tiff
Size: 17326 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20050408/c710112d/attachment.tiff>
-------------- next part --------------

Joshua Ginsberg -- joshg at brainstorminternet.net
Brainstorm Internet Network Operations
970-247-1442 x131
On Apr 8, 2005, at 3:29 PM, SuperJared wrote:

> I'm new to Python, well versed in PHP and a bit of Perl.
>
> I've written a simple backup utility that FTPs from one server to
> another. I'd like to implement exception handling on the FTP should
> someting go wrong.
>
> This is basically what I have so far:
>
>
> try:
>    ftp = FTP(ftp_host, ftp_user, ftp_pass)
>    ftp.storbinary('STOR ' + filename, pointer)
>    ftp.close()
> except:
>    # do something with an error message here...?
>
>
> I'd like to use 'all_errors' but I don't know how! Will I have to
> create a handler for each other exception?
>
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list