Slight irritation with try/finally indentation
Bengt Richter
bokr at oz.net
Fri May 3 21:41:30 EDT 2002
On Fri, 03 May 2002 20:40:57 -0400, Roy Smith <roy at panix.com> wrote:
>Mikko Rantalainen <mira at st.jyu.fi> wrote:
>> Why not the following?
>>
>> try:
>> setup()
>> process()
>> finally:
>> cleanup()
>
>That changes the semantics. Now you're catching errors in setup() as well
>as in process(). If that's what you want, fine, but don't change the
>semantics just to make it looks pretty.
what about the bigger picture? E.g.,:
try:
acquire_resources()
try:
process()
finally:
release_resources()
except AcquireResourceFailure:
handle_resource_acquisition_failure()
except ProcessFailure:
handle_process_failure()
else:
wrap_up_clean_process_completion()
or ??
Regards,
Bengt Richter
More information about the Python-list
mailing list