Eric Nieuwland wrote:
> 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?

As I understand it:

The sliced object will only see integers. The PEP wants to give arbitrary
objects the possibility of pretending to be an integer that can be used
for indexing.

Georg

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to