Todd wrote:
I'm in favor of most of these additions. I was a heavy user of path.py and I'm
missing those "advanced" features in pathlib.
> Stem with no suffixes
>
> The stem property only takes off the last suffix, but even in the example
> given ('my/library.tar.gz') it isn't really useful beca
Today I had a need: I had a tuple of dynamic sequence-like objects. I
wanted to iterate on them reversed, starting with items of the last one and
slowly making my way towards the first one.
In short, I want `reversed(itertools.chain(x, y, z))` that behaves like
`itertools.chain(map(reversed, (z, y
On 9/01/21 10:19 am, Ram Rachum wrote:
In short, I want `reversed(itertools.chain(x, y, z))` that behaves like
`itertools.chain(map(reversed, (z, y, x)))`.
I think you mean `itertools.chain(*map(reversed, (z, y, x)))`
You can get this with
itertools.chain(*map(reversed, reversed(t)))
Mak
On Fri, Jan 08, 2021 at 11:19:40PM +0200, Ram Rachum wrote:
> Today I had a need: I had a tuple of dynamic sequence-like objects. I
> wanted to iterate on them reversed, starting with items of the last one and
> slowly making my way towards the first one.
>
> In short, I want `reversed(itertools.c
On Sat, Jan 9, 2021 at 10:21 AM Steven D'Aprano wrote:
> Not every trivial combination of functions needs to be given a built-in
> or standard library solution. Especially not if doing so will break
> backwards compatibility.
>
> "I had three numbers in a tuple, and wanted half of twice the first
On Sat, Jan 09, 2021 at 11:22:35AM +1300, Greg Ewing wrote:
> Also it's hard to see how it could be made to work, because the
> argument to reversed() necessarily has to be a sequence, not an
> iterator.
No, it just needs a `__reversed__` dunder. It doesn't even need to be an
iterable or sequenc
Traceback (most recent call last):
File "", line 1, in
TypeError: 'itertools.chain' object is not reversible
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/
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 testin
On 9/01/21 12:54 pm, Steven D'Aprano wrote:
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.
Not that surprising, since chain already splits strings into
s