This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "t.py", line 10, in <module> | |
test1()() | |
File "t.py", line 8, in test2 | |
print(e) | |
NameError: free variable 'e' referenced before assignment in enclosing scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def test1(): | |
try: | |
raise Exception("tessssssssssssst") | |
except Exception as e: | |
def test2(): | |
print(e) | |
return test2 | |
test1()() |