2 ms·
Nope, it's more complicated than that: e = 'before' try: x = int('cat') except Exception as e: e2 = e print(e) print(e2
by MyOutfitIsVague 1y ago
Nope, it's more complicated than that:
e = 'before'
try:
x = int('cat')
except Exception as e:
e2 = e
print(e)
print(e2) # <- This works!
print(e) # <- NameError: name 'e' is not defined
It's not a scoping thing, the bound exception variable is actually deleted after the exception block, even if it was already bound before!
- librasteve 1y agolol - raku maybe weird, but at least it has sane variable scoping