except Exception as e:
while does not create a scope in Python. Python has only the following scopes:
So when you leave the
e, being a local variable (if the loop is in a function) or a global variable (if not), is still available.
tl;dr: Python is not C.