"except Foo as bar" causes "bar" to be removed from scope
"except Foo as bar" causes "bar" to be removed from scope Question: Given the following code: msg = “test” try: “a”[1] except IndexError as msg: print(“Error happened”) print(msg) Can somebody explain why this causes the following output in Python 3? Error happened Traceback (most recent call last): File “test.py”, line 6, in <module> print(msg) NameError: …
Total answers: 3