[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

exec and locals

Steven D'Aprano wrote:
>     except SyntaxError:
>         def inner():
>             # manually operate the context manager
>             call context manager __enter__
>             try:
>                 try:
>                     return something
>                 except:  # Yes, a bare except. Catch EVERYTHING.
>                     blah blah blah
>             finally:
>                     call context manager __exit__

Why not just use this version all the time? It should
work in both 2.x and 3.x.