On Sat, Jan 09, 2021 at 10:20:27AM +1100, Steven D'Aprano wrote:
> If I replace the list with itertools.chain, I should still get exactly
> the same results, and I do.
I spoke too soon, I don't. You cannot compose reversed() with chain().
(I don't often make definitive statements without testing them first,
but when I do, I'm invariably wrong.)
(Ram, I guess you had probably already discovered that reversed and
chain can't be composed. It would have been nice for you to have
mention this fact in your proposal, rather than expect every single of
your readers to rediscover it for themselves.)
So in principle we could make the requested change.
However it would still be surprising. I think most people would expect
that if we could compose reversed and chain, the result would be closest
to this:
iterables = (a, b, c) # for example
reversed(list(chain(*iterables)))
rather than your proposal:
iterables = (a, b, c)
rev_iters = tuple(map(reversed, iterables))
reversed(list(*rev_iters))
or equivalent. Your proposal would still have the surprising
consequences that reversing a chain that includes a string would
surprisingly split the string into a sequence of characters in reverse
order.
--
Steve
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/DUWCPAQEZ3YA4N52EHF6DJXDWLLVVP23/
Code of Conduct: http://python.org/psf/codeofconduct/