I need to match cases where the input is iterable. Here's what I tried:
from typing import Iterable
def detector(x: Iterable | int | float | None) -> bool:
match x:
case Iterable():
print('Iterable')
return True
case _:
print('Non iterable')
return False
That is producing this error:
TypeError: called match pattern must be a type
Is it possible to detect iterability with match/case?
Note, these two questions address the same error message but neither question is about how to detect iterability: