[Python-ideas] Add OrderedSet now that OrderedDict is in collections
mrts.pydev at gmail.com
Sun Apr 12 00:22:30 CEST 2009
There was a somewhat ancient discussion on OrderedDict and OrderedSet
The resolution seemed to be that neither of them should be in stdlib. Now
that OrderedDict is in and Raymond Hettinger has created a solid OrderedSet
implementation: http://code.activestate.com/recipes/576694/ , could the
latter also be included in collections?
Here's a very generic use-case:
def _update_key(dct, key, val):
Update a key in dict *dct*. If they key already exists in *dct* but the
value doesn't, a set of previous values is created and the value added
if key in dct:
if dct[key] == val:
s = set(dct[key])
dct[key] = s
dct[key] = val
The problem is that I both need to remove duplicates and retain insertion
order like list.append().
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas