When to use try and except?

Glenn Hutchings zondo42 at googlemail.com
Fri Aug 29 14:26:37 EDT 2008


cnb <circularfunc at yahoo.se> writes:

> A ZeroDivisionError is better avoided wth an if-clause, don't you
> think? It is a predictable exception...

It depends.  If zero-division is unlikely, then things would probably[*]
run faster without checking.  If speed is what you're interested in, that
is...

Glenn

[*] Haven't checked, so don't really know :-)



More information about the Python-list mailing list