Message342389
Serhiy,
`a, *L[::2] = "abc"` as an alternative is interesting, thanks. The other example `L[:], *rest = 'abcdef'` is less interesting because L[:] can be arbitrary size.
When noticing this, I had tried to consume a generator into every other position in a list by using:
L[::2], *extra = g
Though there are obvious workarounds (e.g. using `itertools.islice`), it surprised me that CPython did not "do what I mean" out of the box.
However, since creating the issue, it was brought to my attention that trying to handle this assignment may result in potential ambiguity, for example:
L = [0, 1, 2]
L[::2], *rest = "ab", "c", "d"
There is no obvious choice for result here. So, perhaps this issue should just be closed. |
|
Date |
User |
Action |
Args |
2019-05-13 21:33:08 | wim.glenn | set | recipients:
+ wim.glenn, gvanrossum, georg.brandl, serhiy.storchaka, Windson Yang |
2019-05-13 21:33:08 | wim.glenn | set | messageid: <1557783188.89.0.244266526837.issue36761@roundup.psfhosted.org> |
2019-05-13 21:33:08 | wim.glenn | link | issue36761 messages |
2019-05-13 21:33:08 | wim.glenn | create | |
|