[Python-Dev] PEP 343 rewrite complete
Guido van Rossum
gvanrossum at gmail.com
Wed Jun 1 18:50:39 CEST 2005
[Guido van Rossum]
> > http://www.python.org/peps/pep-0343.html
[Phillip J. Eby]
> 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.
I really don't want a new exception for this, since it's just a bug in
the generator's code. I could go with RuntimeError here too, but I
figured TypeError's meaning in a wider sense applies: the generator
doesn't respond appropriately to the throw() call, which is similar to
not handling a particular argument (list) correctly.
> * The "opening" example under "Generator Decorator" seems to be missing a
> try/finally block.
Good catch. I've fixed this in the PEP.
> * 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.
Ah, of course. I've updated the PEP.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-Dev
mailing list