Perhaps the desired functionality can be spelled as a method? Would it be easy to implement?
On 12/25/2012 8:56 AM, Ram Rachum wrote:
When I have an OrderedDict, I want to be able to delete a slice of it. I
want to be able to do:
del ordered_dict[:3]
To delete the first 3 items, like I would do in a list.
Is there any reason why this shouldn't be implemented?
An OrderedDict is a mapping (has the mapping api) with a defined iteration order (the order of entry). It is not a sequence and does not have the sequence api. Indeed, a DictList is not possible because dl[2] would look for the item associated with 2 as a key rather than 2 as a position. So od[2:3] would *not* be the same as od[2], violating the usually properly of within-sequence length-1 slices.
--
Terry Jan Reedy
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas