[Python-Dev] PEP 310 and exceptions

Phillip J. Eby pje at telecommunity.com
Sat Apr 23 19:50:14 CEST 2005

At 01:41 PM 4/23/05 +1000, Nick Coghlan wrote:
>Whichever way that point goes, this definition would allow PEP 310 to 
>handle Alex's example of factoring out standardised exception handling, as 
>well as the original use case of resource cleanup, and the transaction 
>class transaction(object):
>     def __enter__(self):
>         begin_transaction()
>     def __except__(self, *exc_info):
>         abort_transaction()
>     def __else__(self):
>         commit_transaction()

I'd like to suggest '__success__' in place of '__else__' and 
'__before__'/'__after__' instead of '__enter__'/'__exit__', if you do take 
this approach, so that what they do is a bit more obvious. 

More information about the Python-Dev mailing list