On Tue, 20 Oct 2020 00:00:49 +0200 Thomas Wouters firstname.lastname@example.org wrote:
One of the problems I have with the Pattern Matching proposal (PEP 622 originally, now PEPs 634, 635, 636) is the special-casing of '_' to not actually assign to the name, which is a subtle but meaningful divergence from the rest of Python. In discussions with the authors I proposed using '?' instead *and* extending that to existing unpacking
One problem with this PEP, which I didn't see mentioned in the other replies, is that it tries to grab "?" character, which is already sought-for by another pending PEP: "PEP 505 -- None-aware operators", https://www.python.org/dev/peps/pep-0505/ .
Use of "?" in PEP640 can be disambiguated enough from PEP505's "??", "?.", "?[" from a compiler token perspective perspective, but what about confusion/clarity to humans:
?, ?, c = a d = b?.c ?, c = b ?? (None, 2) e = b?[i]
(And PEP 505 would need to be addressed sooner or later, now that it's part of other mainstream languages. In Python's conceptual debt tower, non-aware operators definitely precede pattern matching).