Hacker News new | ask | show | jobs
by MyOutfitIsVague 331 days 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!
1 comments

lol - raku maybe weird, but at least it has sane variable scoping