[Python-Dev] With statement

Bernhard Herzog bh@intevation.de
04 Feb 2003 15:16:51 +0100


"Moore, Paul" <Paul.Moore@atosorigin.com> writes:

> Alex Martelli suggested transactional processing may be a reasonable use case
> for needing exception handling (commit in __exit__ and rollback in __except__)

I'm not sure an additional __except__ is really needed even for the
transactional use case. It's probably enough to check whether
sys.exc_info()[0] is None to figure out whether __exit__ was called
because of an exception or a regular way of leaving the block.

> but I don't think the gain is worth the extra complexity - I'd say leave this
> coded as now with try...except..else. (Alex - care to convince me otherwise?)

For me the transactional use quite important too. It's the use case that
made me wish for this kind of thing several years ago when I had started
to implement undo in Sketch.


   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Sketch                                 http://sketch.sourceforge.net/
MapIt!                                           http://www.mapit.de/