[Python-Dev] Re: PEP 622: Structural Pattern Matching

2020年6月27日 02:46:40 -0700

Richard Damon writes:
 > I thought _ was also commonly used as:
 > 
 > first, -, last = (1, 2, 3)
 > 
 > as a generic don't care about assignment.
It is. But there are other options (eg, 'ignored') if '_' is used for
translation in the same scope.
 > I guess since the above will create a local, so not overwrite a
 > 'global' function _ for translations, so the above usage works as
 > long as that function (or whatever namespace you are in) doesn't
 > use _ for translations.
Exactly.
 > As long as the bindings in match also make the symbol a local
 > (which seems reasonable) then you would get a similar restriction.
It's quite different. First, it surely won't make other symbols
match-local. Of course there will be times when you do all the work
inside the match statement. But often you'll want to do bindings in a
match statement, then use those outside. The second problem is that
this use of '_' isn't optional. It's part of the syntax. That means
that you can't use the traditional marking of a translateable string
(and it's not just tradition; there is a lot of external software that
expects it) in that scope.
So it's practically important, if not theoretically necessary, that
'case _' not bind '_'.
Steve
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/6SDEJKTXJE4HS5CM2HIGB3ZYS5IN2BAZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to