This code snippet works:
try:
raise Exception('oh no!')
except Exception as e:
error = e
print(error) # prints "oh no!"
This code snippet fails:
try:
raise Exception('oh no!')
except Exception as e:
e = e
print(e) # NameError: name 'e' is not defined
What's going on?