exec and locals
greg.ewing at canterbury.ac.nz
Thu Feb 27 12:29:35 CET 2014
Steven D'Aprano wrote:
> On Thu, 27 Feb 2014 16:34:33 +1300, Gregory Ewing wrote:
>>Why not just use this version all the time? It should work in both 2.x
> Because that's yucky. It's an aesthetic thing: when supported, I want the
> Python interpreter to manage the context manager.
More yucky than wrapping the Py3 version in an
exec? To my way of thinking, that cancels out any
elegance that might have been gained from using
Do you really need to use the context manager
at all? Could you just write the try-statement
that you would have written in Py2 if you
didn't have a context manager?
More information about the Python-list