wim glenn <[email protected]> added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue36761>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com