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 short, this has nothing to do with reversed.  If you made enumerate 
return a sequence when its input is a sequence, you would also be able to 
do enumerate(some_list)[34], which could also be useful.  I think it makes 
Python slightly more perfect and more beautiful.

Best,

Neil
On Thursday, January 21, 2021 at 6:23:20 AM UTC-5 Nuri Jung wrote:

> 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 would be adding a "step" keyword argument to enumerate.
> Then, reversing enumerate would be much easier, like this:
> enumerate(reversed(some_seq), step=-1)
> _______________________________________________
> Python-ideas mailing list -- python...@python.org
> To unsubscribe send an email to python-id...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python...@python.org/message/BW2XKRZ4TSXCFULCS2EU33LLNMIXAL5T/
>  
> <https://mail.python.org/archives/list/python-ideas@python.org/message/BW2XKRZ4TSXCFULCS2EU33LLNMIXAL5T/>
> Code of Conduct: http://python.org/psf/codeofconduct/
>
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/YNJEP32X4VGD2GAMJCDJH6UHLBQHW5AP/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to