coding style - try, except

RGK blank at empty.blank
Wed Feb 25 14:12:01 EST 2009


I'm glad I asked :)

Thanks all who posted for your replies, the else-statement is a nice 
option.

Python again comes through to deal with those pesky feelings that 
something could be better :)

Ross.



Chris Rebert wrote:

> Yes. try-except-*else*.
> 
> try:
>     do_something_1()
>     do_something_2()
> except:
>     print "Houston, we have a problem"
> else: #runs only if no exception was thrown
>     do_something_3()
>     do_something_4()
>     et_cetera()
> 
> Cheers,
> Chris
> 



More information about the Python-list mailing list