On Wed, Jun 02, 2021 at 01:18:30PM +0200, Alexis Masson wrote:

> Anyway, yes, `_` as joker has flaws, the biggest one being to be a 
> resolvable variable name ; what is the expected behaviour when running a 
> script that has (even accidentally) a viariable named `_` ? The question 
> is even more pressing in REPL, since there /is/ necessarily such a 
> variable !

https://www.python.org/dev/peps/pep-0634/#id3

"A wildcard pattern always succeeds. It binds no name."

I'm pretty sure that this means that the intended behaviour is that any 
existing `_` name will be untouched.


    # Untested.
    _ = 'My hovercraft is full of eels.'
    x = 100
    match x:
        case _:
            assert _ == 'My hovercraft is full of eels.'


I would expect that assertion will pass.

Everyone really ought to read the justification for the underscore in 
PEP 635 before commenting further:

https://www.python.org/dev/peps/pep-0635/#id23



-- 
Steve
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/P33QJ2H3OX3G4LE3CIRVD5JSH53ODDH3/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to