Returning to 'try' block after catching an exception
bukzor
workitharder at gmail.com
Wed May 21 20:06:07 EDT 2008
On May 21, 4:33 pm, Karlo Lozovina <_karlo_ at _mosor.net_> wrote:
> André <andre.robe... at gmail.com> wrote innews:a9913f2d-0c1a-4492-bf58-5c78813c4458 at s50g2000hsb.googlegroups.com:
>
> > How about something like the following (untested)
>
> > done = False
> > while not done:
> > try:
> > some_function()
> > done = True
> > except:
> > some_function2()
> > some_function3()
>
> Sure, that works, but I was aiming for something more elegant and Pythonic
> ;).
>
> --
> _______ Karlo Lozovina - Mosor
> | | |.-----.-----. web:http://www.mosor.net|| ICQ#: 10667163
> | || _ | _ | Parce mihi domine quia Dalmata sum.
> |__|_|__||_____|_____|
It's hard to get around a while loop if you want to conditionally
repeat something. There's no built-in way to do what you ask.
More information about the Python-list
mailing list