What's the use of the else in try/except/else?

kj socyl at 987jk.com.invalid
Sun May 10 17:00:23 EDT 2009



I know about the construct:

try:
    # do something 
except ...:
    # handle exception
else:
    # do something else

...but I can't come with an example in which the same couldn't be
accomplished with

try:
    # do something
    # do something else
except ...:
    # handle exception

The only significant difference I can come up with is that in the
second form, the except clause may be masking some unexpected
exceptions from the "do something else" part.  Is this the rationale
behind this else clause?  Or is there something more to it?

TIA!

kynn

-- 
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.



More information about the Python-list mailing list