[Python-Dev] PEP 377 - allow __enter__() methods to skip the statement body
Greg Ewing
greg.ewing at canterbury.ac.nz
Tue Mar 17 01:11:57 CET 2009
Nick Coghlan wrote:
> One of the
> premises of PEP 343 was "Got a frequently recurring block of code that
> only has one variant sequence of statements somewhere in the middle?
> Well, now you can factor that out
Um, no -- it says explicitly right at the very top of
PEP 343 that it's only about factoring out try/finally
statements.
There's no way that
try:
code_block
finally:
...
can fail to enter the code block if you get as far as
the "try". So it's not reasonable to expect the with
statement to provide this ability.
--
Greg
More information about the Python-Dev
mailing list