[Python-Dev] PEP 343 rewrite complete

Phillip J. Eby pje at telecommunity.com
Wed Jun 1 18:16:56 CEST 2005


At 08:16 AM 6/1/2005 -0700, Guido van Rossum wrote:
>I hope that I've got the rewrite of PEP 343 to include generator
>extensions right now. I've chosen the 'with' keyword. Please review
>here; I think this is ready for review by the unwashed masses. :-)
>
>   http://www.python.org/peps/pep-0343.html


Looks great.  A few questions/comments:

* What's the rationale for raising TypeError from close()?  Wasn't 
RuntimeError discussed previously for that role?  (and it's also used by 
the with_template example)  OTOH, maybe that means we want a 
ControlFlowError or some such that can be used for both.

* The "opening" example under "Generator Decorator" seems to be missing a 
try/finally block.

* The transaction handler could also be written as:

     @with_template
     def transactional(db):
         db.begin()
         try:
             yield db
         except:
             db.rollback()
         else:
             db.commit()

at least, if I understand it correctly.
  



More information about the Python-Dev mailing list