[New-bugs-announce] [issue18826] reversed() requires a sequence - Could work on any iterator?
report at bugs.python.org
Sat Aug 24 21:08:22 CEST 2013
New submission from Donald Stufft:
I noticed today that the builtin reversed() requires an explicit sequence and won't work with an iterator instead it throws a TypeError like:
>>> reversed(x for x in [1, 2, 3])
TypeError: argument to reversed() must be a sequence
It would be really great if reversed() worked on iterators too. Currently it requires an explicit list() before you can sent it back into reversed() which seems like it hurts readability.
For what it's worth I discovered this when trying to reverse the output of itertools.dropwhile.
title: reversed() requires a sequence - Could work on any iterator?
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce