This might be easy but I'm not sure how to do that. I have a method looking like this:
def my_method(
self,
coords: Union[Tuple[int, int], Iterable[Tuple[int, int]]
):
...
that is, my_method
needs a tuple of integers or something like a list of tuples of integers (those are some sort of coordinates). Is my typing correct for this?
But my main question, how do I check whether the input is only one tuple like (1,1)
or something like [(1,1),(1,2),..]
or ((1,1),(1,2),..)
or something similar? I heard about isinstance
, but I couldn't figure out how to use this here. Any help is greatly appreciated.