[issue44741] Pattern Matching - star subpattern with a subject derived from collections.abc.Sequence

Pierre Quentel report at bugs.python.org
Tue Jul 27 12:34:24 EDT 2021


Pierre Quentel <pierre.quentel at gmail.com> added the comment:

Oh, I did not invent this class, it is in the test script for pattern matching : https://github.com/python/cpython/blob/6948964ecf94e858448dd28eea634317226d2913/Lib/test/test_patma.py#L1932

With this class, [x, *_, y] matches, but not [x, *w, y] : this is what made me create this issue. Maybe it would be a good idea to change this class in test_patma.py ?

OTOH, if the current implementation remains the same, why does the PEP insist on subjects having a len() ? Could sequence patterns match a wider range of subjects that can be unpacked ?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44741>
_______________________________________


More information about the Python-bugs-list mailing list