Rick Wotnaz wrote: > "Fuzzyman" <[EMAIL PROTECTED]> wrote in > news:[EMAIL PROTECTED]: > > > > > Christoph Zwerschke wrote: > >> - the internal keys list should be hidden > > > > I disagree. It is exposed so that you can manually change the > > order (e.g. to create a "sorted" dict, rather than one ordered > > by key insertion). > > > > What do you *gain* by hiding it ? > > The internal list should be 'hidden' in the sense that it itself > would not be modifiable, though it should be routine to obtain a > copy of it at any time. That copy could then be arranged as needed. > Any rearrangement of the original list's order destroys the reason > for having an entry- or change-ordered dict in the first place. >
That's not the only use case. Other use cases are to have a specific order, not based on entry time. Simple example : d1 = OrderedDict(some_dict.items()) d1.sequence.sort() d1 is now an ordered dict with the keys in alphabetic order. If you don't want to modify sequence, don't. If you want a copy do : seq = d1.sequence[:] All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml > -- > rzed -- http://mail.python.org/mailman/listinfo/python-list