On 12 May 2009 09:35:36 GMT, Steven D'Aprano wrote: [snip] > To really be safe, that should become: > > try: > rsrc = get(resource) > except ResourceError: > log('no more resources available') > raise > else: > try: > do_something_with(rsrc) > finally: > rsrc.close()
Thanks, Steven. I find these examples illuminating. Not trying to be dense, but given that the "except" block re-raises the exception, isn't the above the same as . . .? try: rsrc = get(resource) except ResourceError: log('no more resources available') raise try: do_something_with(rsrc) finally: rsrc.close() -- To email me, substitute nowhere->spamcop, invalid->net. -- http://mail.python.org/mailman/listinfo/python-list