exec and locals
greg.ewing at canterbury.ac.nz
Thu Feb 27 04:34:33 CET 2014
Steven D'Aprano wrote:
> except SyntaxError:
> def inner():
> # manually operate the context manager
> call context manager __enter__
> return something
> except: # Yes, a bare except. Catch EVERYTHING.
> blah blah blah
> call context manager __exit__
Why not just use this version all the time? It should
work in both 2.x and 3.x.
More information about the Python-list