Condider the following example:
>>> {1, True}
set([True])
>>
>>> {True, 1}
set([1])
Why is the set represented differently, depending on the order of the elements?
Condider the following example:
>>> {1, True}
set([True])
>>
>>> {True, 1}
set([1])
Why is the set represented differently, depending on the order of the elements?
This happens because 1
and True
are equal to each other:
>>> True == 1
True
>>> 1 == True
True
The set retains one element from each equality class.
bool is subclass of int class
>>> issubclass(bool, int)
True
>>> True+1
2
>>> True == 1
True