sorteddict PEP proposal [started off as orderedict]

Duncan Booth duncan.booth at invalid.invalid
Thu Sep 27 03:32:03 EDT 2007


Paul Hankin <paul.hankin at gmail.com> wrote:

>> A key which is in dict must be either in __keycache or in __addkeys, but
>> never in both.
> 
> Yes, I'm sorry: you're right.
> 
> But there's a different bug: if you delete a key that's not in the
> dict, you'll add it to the deleted list before the exception for the
> missing key is raised.
> 
> sd = sorteddict.sorteddict()
> sd['a'] = 'a'
> print sd.keys() = ['a']
> try:
>     del sd['b']
> except:
>     pass
> sd['b'] = 'b'
> print sd.keys()
> 
> The second print statement produces ['a'] rather than ['a', 'b']

Yes, I think there are probably several cases where I need to account for 
exceptions.

There's another serious problem: if Mark wants this module to be used and 
stand any chance at all of eventually being incorporated into the standard 
library, then he will have to change the license on his code: the GPL 
simply isn't an option here.



More information about the Python-list mailing list