Alan G Isaac wrote: > Diez B. Roggisch wrote: >> Not really, but that depends on what you know about the concept of sets and >> maps as collections of course. >> >> The contract for sets and dicts doesn't imply any order whatsoever. Which is >> essentially the reason why >> >> set(xrange(10))[0] >> >> doesn't exist, and quite a few times cries for an ordered dictionary as part >> of the standard libraries was made. > > It seems to me that you are missing the point, > but maybe I am missing your point. > > The question of whether a set or dict guarantees > some order seems quite different from the question > of whether rerunning an **unchanged program** yields the > **unchanged results**. The latter question is the question > of replicability. > > Again I point out that some sophisticated users > (among which I am not numbering myself) did not > see into the source of this "anomaly". This > suggests that an explicit warning is warranted.
http://docs.python.org/lib/typesmapping.html """ Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends on the dictionary's history of insertions and deletions. """ The sets documentation is a bit less explicit, though. http://docs.python.org/lib/types-set.html """ Like other collections, sets support x in set, len(set), and for x in set. Being an unordered collection, sets do not record element position or order of insertion. """ -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list