On Tue, 12 May 2009 20:23:25 +1200, Lawrence D'Oliveiro wrote:

> In message <gu7f97$mt...@reader1.panix.com>, kj wrote:
> 
>> I know about the construct:
>> 
>> try:
>>     # do something
>> except ...:
>>     # handle exception
>> else:
>>     # do something else
>> 
>> ...but I can't come with an example in which the same couldn't be
>> accomplished with [no else]
> 
> I'd agree. If you have to resort to a "try .. else", then might I
> respectfully suggest that you're using exceptions in a way that's
> complicated enough to get you into trouble.



try:
    rsrc = get(resource)
except ResourceError:
    log('no more resources available')
    raise
else:
    do_something_with(rsrc)
finally:
    rsrc.close()



is complicated? It seems pretty straightforward to me.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to