When to use try and except?

cnb circularfunc at yahoo.se
Fri Aug 29 13:23:16 EDT 2008


If I get zero division error it is obv a poor solution to do try and
except since it can be solved with an if-clause.

However if a program runs out of memory I should just let it crash
right? Because if not then I'd have to write exceptions everywhere to
prevent that right?

So when would I actually use try-except?

If there can be several exceptions and I just want to catch 1 or 2?
Like
try:
    blahaba
except SomeError:
    do something



More information about the Python-list mailing list