In other languages that support match, whether functional or not, you are not changing the value of the variable, but you are shadowing/rebinding the identifier inside the scope of the match clause.
In other languages that support match, whether functional or not, you are not changing the value of the variable, but you are shadowing/rebinding the identifier inside the scope of the match clause.
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.)
In my mind that is not well thought out.