Jul-11-2024, 06:58 AM
(Jul-11-2024, 12:06 AM)Skaperen Wrote: what will that do if obj is a set? my thinking of a set is that it is iterable but it is not a sequence.
>>> from collections.abc import Iterable, Sequence >>> isinstance(set(), Iterable) True >>> isinstance(set(), Sequence) False >>>What is a sequence in your view? Is it snippsat's definition or is it the interface of collections.abc.Sequence or do you have your own definition?
Another question is what do you want to do with this? For what purpose do you test if something is a sequence in your code?
« We can solve any problem by introducing an extra level of indirection »