On Fri, Apr 26, 2019 at 12:17:57AM -0400, Terry Reedy wrote:
> On 4/25/2019 7:12 PM, Greg Ewing wrote:
> >Steven D'Aprano wrote:
> >>I too often forget that reverse() returns an iterator,
>
> I presume you mean reversed(). list.reverse() is a list
Yes, I meant reversed(), not list.reverse()
On Fri, Apr 26, 2019 at 11:12:51AM +1200, Greg Ewing wrote:
> Steven D'Aprano wrote:
> >I too often forget that reverse() returns an iterator,
>
> That seems like a mistake. Shouldn't it return a view?
I don't know what it "should" or "shouldn't" it return, but it actually
does return an
On 4/25/2019 7:12 PM, Greg Ewing wrote:
Steven D'Aprano wrote:
I too often forget that reverse() returns an iterator,
I presume you mean reversed(). list.reverse() is a list
That seems like a mistake. Shouldn't it return a view?
RL = reversed(somelist) is already partly view-like. The
Steven D'Aprano wrote:
I too often forget that reverse() returns an iterator,
That seems like a mistake. Shouldn't it return a view?
--
Greg
___
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
On Wed, Apr 24, 2019 at 01:50:48AM +0800, Thautwarm Zhao wrote:
> However, the reason why we don't need list.rindex but do for str.rindex is
> simple I'd say: str is immutable and has no O(1) reverse method.
>
> On the other hand, when it comes to list, you can use list.index after
>
On Tue, Apr 23, 2019 at 10:28:29AM -0700, Brett Cannon wrote:
> Given "abcdefabcdefabcdef", what is the last result of "abc"?
> x.rindex("abc") will tell you.
>
> Given [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] where is the last result of 3?
> reversed(x).index(3) will tell you (or x[::-1]).
That first
On Wed, Apr 24, 2019 at 08:59:18AM +0800, 林自均 wrote:
> Hi all,
>
> Thanks for the explanation. Now I agree that the need for list.rindex() is
> not as common as str.rindex(). In fact, I only need list.rindex() when
> doing some algorithm problems. I guess that doesn't count as real need here.
Of
Hi all,
Thanks for the explanation. Now I agree that the need for list.rindex() is
not as common as str.rindex(). In fact, I only need list.rindex() when
doing some algorithm problems. I guess that doesn't count as real need here.
Best,
John Lin
Guido van Rossum 於 2019年4月24日 週三 上午4:20寫道:
> On
On Tue, Apr 23, 2019 at 1:02 PM MRAB wrote:
> On 2019-04-23 18:52, Terry Reedy wrote:
> > On 4/23/2019 2:44 AM, 林自均 wrote:
> >> Hi all,
> >>
> >> I found that there are str.index() and str.rindex(), but there is only
> >> list.index() and no list.rindex().
> >
> > str.index and list.index are
On 2019-04-23 18:52, Terry Reedy wrote:
On 4/23/2019 2:44 AM, 林自均 wrote:
Hi all,
I found that there are str.index() and str.rindex(), but there is only
list.index() and no list.rindex().
str.index and list.index are related but not the same. The consistency
argument is better applied to
On 4/23/2019 2:44 AM, 林自均 wrote:
Hi all,
I found that there are str.index() and str.rindex(), but there is only
list.index() and no list.rindex().
str.index and list.index are related but not the same. The consistency
argument is better applied to find-rfind, index-rindex,
ot;
> Today's Topics:
>
>1. What are the strong use cases for str.rindex()? (???)
>
>
>
> -- Forwarded message --
> From: "林自均"
> To: python-ideas@python.org
> Cc:
> Bcc:
> Date: Tue, 23 Apr 2019 14:44:25 +0800
> Subject: [Python-ideas] What are the strong
Given "abcdefabcdefabcdef", what is the last result of "abc"?
x.rindex("abc") will tell you.
Given [1, 2, 3, 4, 5, 1, 2, 3, 4, 5] where is the last result of 3?
reversed(x).index(3) will tell you (or x[::-1]).
Notice how with lists you can easily reverse them and still get at the
value since you
Hi all,
I found that there are str.index() and str.rindex(), but there is only
list.index() and no list.rindex(). So I filed the issue
https://bugs.python.org/issue36639 to provide list.rindex(). However, the
issue was rejected and closed with the comment:
> There were known, strong use cases
14 matches
Mail list logo