I have not seen the implementation details of the set Class
but I assume the answer to this is there somewhere. Python assignment basically evaluates rvalues and uses an identifier as reference object to point to the class object. Same for collections, i.e. they are an abstract data structure or a 'collection' of reference object. Sets don't allow duplicates and when I create a set like so:
s1 = {False, 1.0, 1, "a"} > {False, 1.0, "a"}
Float class wins over int class, obviously they evaluate to the same thing. But why does float show and init doesn't? I can't seem to find a decent answer or see it in the source.
As an aside I'd like to mention I noticed that True and False will be usurped in some way in place of 1 and 0 respectively if both are present using a .union() operation. So Floats win over Ints, and Ints win over Bools it would seem. But,
>>> s1 = {False, 'a', 1}
>>> s2 = {True, 'a', 0}
>>> s1 | s2
{False, 1, 'a'}
False remains.. I don't know if this was a REPL issue but after testing this again I get {0, 1, 'a'}
every time I don't know what happened.
>>> s1 = {True, 'a', 1}
>>> s1
{1, 'a'}
>>> s2 = {False, 'a', 0}
>>> s2
{0, 'a'}
What am I missing?
>>> s1.union(s2)
{0, 1, 'a'}