On Tue, Feb 25, 2014 at 11:27 AM, Jim J. Jewett <jimjjewett@gmail.com> wrote:
This also makes me wonder whether the cost of a subscope (for exception capture) could be limited to when an exception actually occurs, and whether that might lower the cost enough to make the it a good tradeoff.
def myfunc1(a, b, e): assert "main scope e value" == e
e = "main scope e value" value = (myfunc1(val1, val2, e) except e.reason if AppError as e) assert "main scope e value" == e
I'm sure it could. But there aren't many use-cases. Look at the one example I was able to find in the stdlib: http://legacy.python.org/dev/peps/pep-0463/#capturing-the-exception-object It's hardly a shining example of the value of the proposal. Got any really awesome demo that requires 'as'? Most of the supporting examples use something like KeyError where it's simply "was an exception thrown or not". ChrisA