Ilya Kamenshchikov writes:

 > I needed reversed(enumerate(x: list)) in my code,

def reversed_enumerated_list(l):
    return zip(reversed(range(len(l)), reversed(l))

 > and have discovered that it wound't work.

I wouldn't have expected it to, because enumerate's result is
unbounded.  But I'm definitely warming to the idea that this should
work for iterables with known length.  Presumably the same
implementation method used for reversed itself would work; not sure if
that is what you proposed.

The method used to implement reversibility should probably be exposed
so that other code that wants a finite enumeration can determine what
enumerate has discovered about the underlying iterable.
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/22EP2NZMT624AOL4QTAC6VOKOXOLY7ZM/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to