Python `match` statements do not introduce a new scope.
The second example does indeed change the value of `not_found`.
The second example does indeed change the value of `not_found`.
The only clause I can find in the PEP is
> A capture pattern always succeeds. It binds the subject value to the name using the scoping rules for name binding established for named expressions in PEP 572. (Summary: the name becomes a local variable in the closest containing function scope unless there's an applicable nonlocal or global statement.)
This seems... incredibly bad.
In Python 2.7 you get this:
>>> my_list = [x for x in 'hello']
>>> x
'o'(That is, for, if, while, etc. also don't introduce new scopes.)