Order of insertion in sets (when parsing {}) [duplicate]
问题 This question already has an answer here : Dict/Set Parsing Order Consistency (1 answer) Closed 2 years ago . Someone asked here why when putting 1 and True in a set only 1 is kept. This is of course because 1==True . But in which cases 1 is kept and in which cases True is kept? Let's see: passing a list to build the set instead of using the set notation: >>> set([True,1]) {True} >>> set([1,True]) {1} seems logical: set iterates on the inner list, and doesn't add the second element because it