This has to do with the new Python 3.10 beta and the new match
syntax.
Is there any way to check if a pattern is simply contained in an iterable? the most obvious solution, to simply put two wildcards on either side, but that raises a SyntaxError
due to the unpacking syntax coming from iterable unpacking.
Is there any possible way to do this?
NOTE: the use of things like wrapper classes around numbers
in the example would be fine, as long as it works using the match blocks and is at least somewhat readable, but I have already tried this somewhat and not had much success
example:
numbers = [1, 2, 3, 5, 7, 8, 9] #does not have to be a list, could be a class if needed
match numbers:
# this just raises a SyntaxError, but I need a way to do something equivalent to this
case [*_, (5 | 6), *_]:
print("match!")