[Python-ideas] Deprecating the old-style sequence protocol

Guido van Rossum guido at python.org
Tue Jan 5 11:45:11 EST 2016


Or maybe Indexable is fine after all, since the arguments to __getitem__
are supposed to be objects with an __index__ method (e.g. Integral, but not
Real).

BTW, Maybe Index needs to be added to numbers.py as an ABC? PEP 357, which
introduced it, sounds like it pre-dates ABCs.

On Tue, Jan 5, 2016 at 6:13 AM, Alexander Walters <tritium-list at sdamon.com>
wrote:

> Devils Advocate:  Please don't make me press shift more than twice in a
> base class name if you expect me to use it.  It just makes annoying
> avoidable typos more common.
>
> 'Subscripted' sounds good to me, if that's worth anything.
>
>
> On 1/5/2016 00:50, Nick Coghlan wrote:
>
>> On 5 January 2016 at 12:46, Andrew Barnert via Python-ideas
>> <python-ideas at python.org> wrote:
>>
>>> On Jan 4, 2016, at 12:31, Guido van Rossum <guido at python.org> wrote:
>>>
>>> On Fri, Jan 1, 2016 at 2:25 PM, Andrew Barnert <abarnert at yahoo.com>
>>> wrote:
>>>
>>>> On Dec 27, 2015, at 09:04, Guido van Rossum <guido at python.org> wrote:
>>>>
>>>>> If we really want a way to turn something that just supports
>>>>> __getitem__
>>>>> into an Iterable maybe we can provide an additional ABC for that
>>>>> purpose;
>>>>> let's call it a HalfSequence until we've come up with a better name.
>>>>> (We
>>>>> can't use Iterable for this because Iterable should not reference
>>>>> __getitem__.)
>>>>>
>>>> #25988 (using Nick's name Indexable, and the details from that post).
>>>>
>>> Oh, interesting. Though I have misgivings about that name.
>>>
>>> Now that you mention it, I can see the confusion. I interpreted Nick's
>>> "Indexable" to mean "subscriptable by indexes (and slices of indexes)" as
>>> opposed to "subscriptable by arbitrary keys". But if I didn't already
>>> know
>>> what he intended, I suppose I could have instead guessed "usable as an
>>> index", which would be very misleading.
>>>
>>> There don't seem to be any existing terms for this that don't relate to
>>> "sequence", so maybe your HalfSequence (or Sequential or
>>> SequentiallySubscriptable or something even more horrible than that last
>>> one?) is the best option?
>>>
>>> Or, hopefully, someone _can_ come up with a better name. :)
>>>
>> I mainly suggested Indexable because it was the least-worst name I
>> could think of, and I'd previously suggested Index as the name for
>> "has an __index__ method" (in the context of typing, but it would also
>> work in the context of collections.abc).
>>
>> The main alternative I've thought of is "IterableByIndex", which is
>> both explicit and accurate, with the only strike against it being
>> length.
>>
>> Cheers,
>> Nick.
>>
>>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>



-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160105/7306c627/attachment.html>


More information about the Python-ideas mailing list