El mié, 2 jun 2021 a las 8:34, Alexis Masson (<a.masson...@ntymail.com>) escribió:
> Yeah, that's it exactly. > > I see these two features - `_` as a joker in `match` statements and `_`as > the last value produced by a shell - as incompatible, because you have to > account for interferences between them, or face unexpected behaviors in > code you run. > > I expect people to code like I do : first experiment a feature in a shell, > then write a clean script that implements it cleanly. To debug that script, > go back to the shell to run the script bit by bit, etc, etc. > You'd expect code that runs in a shell to behave the same in a script, and > vice-versa. But, if `_` is both a variable (shell) and a keyword (`match`), > that 's not the case. You have to work around the problem, e.g. by > reaffecting `_`. > My fear is that most people (me included) will most likely forget this > step when switching between a shell and a script. > > What concretely is the difference you're concerned about? `_` in patterns doesn't actually bind the name, so you can still use it in the shell for the last evaluated expression.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/WQO5APLMQ6KHC2RXQ7L67LX6ZBJZQEFM/ Code of Conduct: http://python.org/psf/codeofconduct/