[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Random832
On Thu, Jan 21, 2021, at 19:19, Chris Angelico wrote: > Yeah, I don't think that'll work if you slice more than once, > especially with some iteration in between. I think part of the point of this implementation [or the other person's suggestion of having a "collection view", which amounts to

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Chris Angelico
On Fri, Jan 22, 2021 at 11:48 AM Neil Girdhar wrote: > If enumerate(some_sequence) returns a sequence view, iterating over > that sequence view does not advance it—just like how DictViews are not > altered by iteration. Same thing if reversed(some_sequence) returns a > sequence view. Then

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Neil Girdhar
On Thu, Jan 21, 2021 at 7:19 PM Chris Angelico wrote: > > On Fri, Jan 22, 2021 at 11:10 AM Random832 wrote: > > > > On Thu, Jan 21, 2021, at 18:48, Chris Angelico wrote: > > > Note that slicing is NOT easy. The proposed semantics for a reversed > > > enumeration would make slicing extremely odd.

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Chris Angelico
On Fri, Jan 22, 2021 at 11:10 AM Random832 wrote: > > On Thu, Jan 21, 2021, at 18:48, Chris Angelico wrote: > > Note that slicing is NOT easy. The proposed semantics for a reversed > > enumeration would make slicing extremely odd. > > What proposed semantics? You were the one who posted a

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Random832
On Thu, Jan 21, 2021, at 18:48, Chris Angelico wrote: > Note that slicing is NOT easy. The proposed semantics for a reversed > enumeration would make slicing extremely odd. What proposed semantics? You were the one who posted a pure-python implementation that didn't bother to implement slicing.

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Chris Angelico
On Fri, Jan 22, 2021 at 8:31 AM Neil Girdhar wrote: > It's possible for reversed(enumerate(...)) to just work if enumerate > of a sequence were to return a sequence view. Then you would also get > all the other sequence operations for free like enumerate(...)[23:27], > len(enumerate(...)), etc.

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Neil Girdhar
On Thu, Jan 21, 2021 at 3:13 PM Christopher Barker wrote: > > On Thu, Jan 21, 2021 at 10:43 AM Neil Girdhar wrote: >> >> > > I've seen this proposed here before. The general idea is that some >> > > iterator transformations (like enumerate) should return sequences when >> > > they're applied

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Christopher Barker
On Thu, Jan 21, 2021 at 10:43 AM Neil Girdhar wrote: > > > I've seen this proposed here before. The general idea is that some > iterator transformations (like enumerate) should return sequences when > they're applied to sequences. I'm not so sure -- I don't think I want a sequence returned.

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Chris Angelico
On Fri, Jan 22, 2021 at 5:44 AM Neil Girdhar wrote: > > On Thu, Jan 21, 2021 at 1:26 PM Chris Angelico wrote: > > > > On Fri, Jan 22, 2021 at 5:21 AM Neil Girdhar wrote: > > > > > > I've seen this proposed here before. The general idea is that some > > > iterator transformations (like

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Neil Girdhar
On Thu, Jan 21, 2021 at 1:26 PM Chris Angelico wrote: > > On Fri, Jan 22, 2021 at 5:21 AM Neil Girdhar wrote: > > > > I've seen this proposed here before. The general idea is that some > > iterator transformations (like enumerate) should return sequences when > > they're applied to sequences.

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Chris Angelico
On Fri, Jan 22, 2021 at 5:21 AM Neil Girdhar wrote: > > I've seen this proposed here before. The general idea is that some iterator > transformations (like enumerate) should return sequences when they're applied > to sequences. I think it's good idea, but it adds complexity and work, which >

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Neil Girdhar
I've seen this proposed here before. The general idea is that some iterator transformations (like enumerate) should return sequences when they're applied to sequences. I think it's good idea, but it adds complexity and work, which I guess needs to be justified on a case-by-case basis. In

[Python-ideas] Re: [Python-Dev] reversed enumerate

2021-01-21 Thread Nuri Jung
So, what is the conclusion? I also think reversed(enumerate(some_seq)) will be very useful in many cases. It should: 1) work the same as reversed(tuple(enumerate(...))) for "reversible" objects as argument of enumerate, 2) raise TypeError if the object is not reversible. Or, another option