Python's Exception, and Capitalization

Aahz aahz at pythoncraft.com
Fri Aug 12 11:45:56 EDT 2005


In article <1123856890.712908.247920 at o13g2000cwo.googlegroups.com>,
Ray <ray_usenet at yahoo.com> wrote:
>
>2. I'm quite baffled that you either have try/except, or try/finally.
>In Java, it is quite common to do this:
>
>try {
>    // something
>} catch(AException e) {
>    // handle
>} catch(BException e) {
>    // handle
>} catch(CException e) {
>    // handle
>} finally {
>    // whatever happens, execute this
>}
>
>It seems that since except and finally are mutually exclusive I can't
>do this. So... what's the usual idiom for this?

Keep in mind that Python actually predates Java.  The way this is
handled now is

    try:
        try:
        except:
        else:
    finally:

Way back when, Guido thought that it would be confusing to allow both
except and finally clauses in the same try because people wouldn't know
what ordering to use (particularly with the else clause).
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

The way to build large Python applications is to componentize and
loosely-couple the hell out of everything.



More information about the Python-list mailing list