[Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation (original) (raw)
Eric Nieuwland eric.nieuwland at xs4all.nl
Thu Feb 9 09:46:12 CET 2006
- Previous message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Next message: [Python-Dev] PEP for adding an sq_index slot so that any object, a or b, can be used in X[a:b] notation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]