Ordering python sets

Peter Pearson ppearson at nowhere.invalid
Wed Oct 22 12:30:45 EDT 2008


On Wed, 22 Oct 2008 15:37:03 +0200, Peter Otten <__peter__ at web.de> wrote:
> Tim Chase wrote:
>
>> Though for each test, in 2.3, 2.4, and 2.5 that I've got
>> installed on my local machine, they each printed "s" in-order,
>> and the iteration occurred in-order as well, even without the
>> added "sorted(list(s))" code.
>
> You need more tests then ;)
>
>>>> list(set([1,1000]))
> [1000, 1]

So one wonders, of course, why Mr. Otten chose 1000; and one explores:

$ python
Python 2.4.3 (#2, Jul 31 2008, 21:56:52)
[snip]
>>> for x in 2, 100, 199, 200, 300, 400, 500, 600:
...   list( set( [ 1, x ] ) )
...
[1, 2]
[1, 100]
[1, 199]
[200, 1]
[1, 300]
[400, 1]
[1, 500]
[600, 1]
>>>


-- 
To email me, substitute nowhere->spamcop, invalid->net.



More information about the Python-list mailing list