4 ms·
Tuple, list, and numpy array are all different isinstance()’s, so I’d have to call them all out. len() avoids that.
by mturmon 5y ago
Tuple, list, and numpy array are all different isinstance()’s, so I’d have to call them all out. len() avoids that.
- saila 5y agoThis is incorrect, because you can generally do this for sequence types: isinstance(items, Sequence) Or perhaps: isinstance(items, Iterable) # works with numpy arrays Or, equivalent to using len() for type checking, you could do: isinstance(items, Sized)