Question about exception-handling mechanism

Moshe Zadka moshez at
Tue Apr 25 19:47:55 CEST 2000

On Tue, 25 Apr 2000 willfg at wrote:

> Hello all,
>    I'm new to Python, but find its exception handling mechanism much
> more powerful than comparable languages; but a question was put to me
> that being new I can't come up with a very articulate answer. A
> colleague asked why in an exception handling mechanism you'd want the
> ELSE block to be executed if you don't throw an exception as opposed to
> a FINALLY block. Anyone used this feature in practice? Thanks in
> advance for your input, -- Will

Lots of time.

Consider some sort of

def f(file):
		fp = open(file)
	except IOError:
		return 0 # it doesn't exist

To check if a certain file is both readable and is a zip-file. You don't
want the except to cover the "read" -- an error in read is unexpected.
Moshe Zadka <mzadka at>. -- we put the penguin in .com

More information about the Python-list mailing list