Message402887
If you are working in the interactive interpreter, you may be running into a conflict with the "magic" variable `_` which the interactive interpreter creates to hold the result of the last evaluated statement.
So when you evaluate `x`, and that returns the string "robert", it also gets assigned to `_`. But you can't easily delete `_` because it lives in the builtin namespace, not the global namespace.
This happens with anything, not just match statements:
>>> x = "spam eggs"
>>> x
'spam eggs'
>>> _
'spam eggs'
>>> del _ # Not a global, can't delete it!
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name '_' is not defined
So I think the weird behaviour with _ that you have stumbled over is a red herring.
However, it does seem to me that *perhaps* the assignment to x shouldn't be occurring at all. So that may be a bug in the match statement? |
|
Date |
User |
Action |
Args |
2021-09-29 15:56:10 | steven.daprano | set | recipients:
+ steven.daprano, ojob |
2021-09-29 15:56:10 | steven.daprano | set | messageid: <1632930970.09.0.203977779052.issue45323@roundup.psfhosted.org> |
2021-09-29 15:56:10 | steven.daprano | link | issue45323 messages |
2021-09-29 15:56:10 | steven.daprano | create | |
|