I've been playing around with Structural Pattern Matching in Python 3.10 and can't figure out how to get it to match a set. For example I've tried:
a = {1,2,3}
match a:
case set(1,2,3):
print('matched')
and I've tried:
a = {1,2,3}
match a:
case set([1,2,3]):
print('matched')
As well as:
a = {1,2,3}
match a:
case [1,2,3] if isinstance(a, set):
print('matched')
I'm guessing there is a way to do this since we can match other objects and I'm just missing the correct syntax but I can't think of what else to try. Any help would be appreciated! Thanks!
case {a, b, c}:how would it know which variable should get each value in the set, since sets don't have any order?switch/case. That's not the intended use.