[issue45323] unexpected behavior on first match case _

2021-09-30 Thread Joël Bourgault
Joël Bourgault added the comment: Complement: the Python tutorial presents the "magic _" in the following section, close to its end: https://docs.python.org/3/tutorial/introduction.html#numbers > In interactive mode, the last printed expression is assigned to the variable > _. -- _

[issue45323] unexpected behavior on first match case _

2021-09-30 Thread Joël Bourgault
Change by Joël Bourgault : -- assignee: -> docs@python components: +Documentation nosy: +docs@python ___ Python tracker ___ ___ Pyth

[issue45323] unexpected behavior on first match case _

2021-09-30 Thread Joël Bourgault
Joël Bourgault added the comment: I obtain the reported behaviour using `python -m doctests .md` in a Gitlab pipeline, so it is likely that the execution is similar to the Python interpreter. Therefore, I am satisfied by your answer, so I close this 'bug'; thanks a lot! Now, about the fact t

[issue45323] unexpected behavior on first match case _

2021-09-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: It is a bit tricky to find the documentation for the magic single underscore, but it is here: https://docs.python.org/3/reference/lexical_analysis.html#reserved-classes-of-identifiers -- ___ Python tracker

[issue45323] unexpected behavior on first match case _

2021-09-29 Thread Steven D'Aprano
Steven D'Aprano added the comment: 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

[issue45323] unexpected behavior on first match case _

2021-09-29 Thread Joël Bourgault
New submission from Joël Bourgault : While testing the `match...case` construction, I get the following behavior with Docker image Python 3.10 rc2-slim: ```python >>> match "robert": ... case x if len(x) > 10: ... print("long nom") ... case [0, y]: ... print("point à x n