A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-June/080419.html below:

[Python-Dev] Proposal: add odict to collections

[Python-Dev] Proposal: add odict to collections"Martin v. Löwis" martin at v.loewis.de
Sun Jun 15 09:41:32 CEST 2008
> I compared multiple ordered dicts now (including Babel, Django and the
> C-implementation I mentioned earlier) and implemented a python version
> of the ordered dict as reference implementation:
> 
>    http://dev.pocoo.org/hg/sandbox/raw-file/tip/odict.py

I find the slicing API surprising. IMO, if you do support slicing, then
a) the start and end indices should be the same ones that you also use
   in regular indexing.
b) the result should be of the same kind as the thing being sliced, i.e.
   an odict.

So I would rather expect

>>> d['c':'spam']
odict.odict([('c', 'd'), ('foo', 'bar')])

The slicing operation that you provide should be spelled as
d.items()[1:3], or, if you don't want to pay the cost of creating
the full items list, then add a method such as d.slice_by_index(1,3).
What's the use case for this operation, anyway?

Regards,
Martin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4