[Python-ideas] Allow deleting slice in an OrderedDict
Nick Coghlan
ncoghlan at gmail.com
Wed Dec 26 08:27:52 CET 2012
(replying again, as the original somehow had a broken googlegroups.com
address instead of the proper python.org one)
On Tue, Dec 25, 2012 at 11:56 PM, Ram Rachum <ram.rachum at gmail.com> 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?
Yes, because if you want to do that, you need a list, not an ordered
dictionary. Don't try to lump every possible operation into one
incoherent uber-type. If you need mutable list-like behaviour *and*
mapping behaviour, you're better off with an ordinary mapping and a
separate list of keys.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas
mailing list