Why are there no ordered dictionaries?

Tom Anderson twic at urchin.earth.li
Wed Nov 23 02:44:52 CET 2005


On Tue, 22 Nov 2005, Carsten Haese wrote:

> On Tue, 2005-11-22 at 14:37, Christoph Zwerschke wrote:
>
>> In Foord/Larosa's odict, the keys are exposed as a public member which 
>> also seems to be a bad idea ("If you alter the sequence list so that it 
>> no longer reflects the contents of the dictionary, you have broken your 
>> OrderedDict").
>
> That could easily be fixed by making the sequence a "managed property" 
> whose setter raises a ValueError if you try to set it to something 
> that's not a permutation of what it was.

I'm not a managed property expert (although there's a lovely studio in 
Bayswater you might be interested in), but how does this stop you doing:

my_odict.sequence[0] = Shrubbery()

Which would break the odict good and hard.

tom

-- 
When I see a man on a bicycle I have hope for the human race. --
H. G. Wells



More information about the Python-list mailing list