Set() and {} appear to give very similar behaviour, except for the confounding set([]) and {}. In the following comparisons, why is the last one False?
>>> set([1,2,3])=={1,2,3}
True
>>> set([1,2,3])==set([1,2,3])
True
>>> {1,2,3}=={1,2,3}
True
>>> set([])==set([])
True
>>> {}=={}
True
>>> set([])=={}
False
Because the {} literal is reserved for the empty dict, not the empty set
Because {} creates a dict.
In[49]: type({})
Out[49]: dict
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With