On Wed, Oct 22, 2008 at 4:30 PM, Roy Smith <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > Mr.SpOOn <[EMAIL PROTECTED]> wrote: > >> It seems to me that it orders elements when you add using the add() >> method, but if you create a set starting from a list, it may result >> unordered. > > Arrrggghhh! None of these behaviors are guaranteed. The docs say, "A set > object is an unordered collection". If you write code which depends on a > set preserving order, are going to get burned.
Yes, of course :D I wasn't going to count on that. > If you want something that preserves order, use a list. If the O(n) lookup > time of a list is too slow, you can get O(log n) with heapq. Well, maybe I can just do it using sets and the sorted() method. If this doesn't satisfy me, I think I'll just use lists. -- http://mail.python.org/mailman/listinfo/python-list