[issue46692] match case does not support regex
Eric V. Smith
report at bugs.python.org
Wed Feb 9 09:13:51 EST 2022
Eric V. Smith <eric at trueblade.com> added the comment:
Oops, slight bug in my code. Use this:
import re
def f(map):
print(f'input={map["one"]} {map["two"]}')
match map:
case {'one': x, 'two': y}:
print(f"match {x} {y}")
case _:
print("no match")
d = {'one':0, 'two':1}
f(d)
m = re.match("(?P<one>a)b(?P<two>c)", "abc")
f(m)
With this output:
input=0 1
match 0 1
input=a c
no match
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46692>
_______________________________________
More information about the Python-bugs-list
mailing list