Consider the following in Python
>>> my_set = set( (((((1,2))))) )
>>> my_set
{1, 2}
>>> my_obj = (((((1,2)))))
>>> type(my_obj)
tuple
I am perplexed by this behavior. My understanding is that set
expects an iterable, and a tuple
is an iterable, so shouldn't my_set
be initialized with the first element in (((((1,2)))))
, i.e. ((((1,2))))
, instead of with the values 1
and 2
?