Returning to 'try' block after catching an exception

Karlo Lozovina _karlo_ at _mosor.net_
Thu May 22 04:15:52 EDT 2008


alex23 <wuwei23 at gmail.com> wrote in
news:485f7ddc-8f50-4483-b591-151f1ae560be at k10g2000prm.googlegroups.com: 

> If you know what exception to expect, and you know how to "fix" the
> cause, why not just put tests _before_ some_function() is called to
> ensure that everything is as it needs to be?

Because when you expect exception to occur on something like 0.01% of 
cases, and you have 4 or 5 exceptions and the code to test for each 
conditions that cause exceptions is quite long and burried deep inside 
some other code it's much better to do it this way ;). Too bad there's no 
syntactic sugar for doing this kind of try-except loop.


-- 
 _______                                        Karlo Lozovina - Mosor
|   |   |.-----.-----.     web: http://www.mosor.net || ICQ#: 10667163
|       ||  _  |  _  |             Parce mihi domine quia Dalmata sum.
|__|_|__||_____|_____|



More information about the Python-list mailing list