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/2006-February/060596.html below:

[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation

[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notationEric Nieuwland eric.nieuwland at xs4all.nl
Thu Feb 9 09:46:12 CET 2006
Travis Oliphant wrote:
> PEP:  ###
> Title:  Allowing any object to be used for slicing
> [...]
> Rationale
>
>    Currently integers and long integers play a special role in slice
>    notation in that they are the only objects allowed in slice
>    syntax. In other words, if X is an object implementing the sequence
>    protocol, then X[obj1:obj2] is only valid if obj1 and obj2 are both
>    integers or long integers.  There is no way for obj1 and obj2 to
>    tell Python that they could be reasonably used as indexes into a
>    sequence.  This is an unnecessary limitation.
> [...]

I like the general idea from an academic point of view.
Just one question: could you explain what I should expect from x[ 
slicer('spam') : slicer('eggs') ]  when slicer implements this 
protocol?
Specifically, I'd like to known how you want to define the interval 
between two objects. Or is that for the sliced/indexed object to 
decide?

--eric

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