I think this method would be useful for list itself (maybe tuple, but I
care less about that). It certainly should not be part of the Sequence
protocol.

I have often programmed a pattern where I .append() elements to a list in a
loop, and *expect* at least N things to make it in.  In such case, getting
a sentinel answer to mylist.get(N-1) would be convenient.

Obviously, I've lived without that fine. But it's a little bit shorter and
more expressive than:

    x = mylist[N-1] if len(mylist) >= N else None

On Wed, Aug 26, 2020, 1:30 PM Guido van Rossum <[email protected]> wrote:

> But for your convenience you are proposing a problematic change (see posts
> by others). Maybe I meant overgeneralization instead.
>
> On Wed, Aug 26, 2020 at 10:20 AM Alex Hall <[email protected]> wrote:
>
>> On Wed, Aug 26, 2020 at 4:32 PM Guido van Rossum <[email protected]>
>> wrote:
>>
>>> FWIW I don’t think we should add a .get() method for Sequence or for
>>> list. It reeks of hyper-correctness.
>>>
>>
>> What do you mean by this? I want the method because it's useful and
>> convenient, not because it's 'correct'. I don't think that lists are
>> 'wrong' right now.
>>
>
>
> --
> --Guido van Rossum (python.org/~guido)
> *Pronouns: he/him **(why is my pronoun here?)*
> <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-change-the-world/>
> _______________________________________________
> Python-ideas mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/D7JMHGT4VE3ZIXPVHD4FQMIDLJ6H2H4V/
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/B3KJKBAAO5T5PBK6JPEMBPKIBP67QC5F/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to