Re:Python built-ins worth learning (2019)
by mturmon on Thursday March 24, 2022 @01:54AM
(#30786729)
Tuple, list, and numpy array are all different isinstance()’s, so I’d have to call them all out. len() avoids that.
[ Parent
| on HN ]
This 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)