[issue36761] Extended slice assignment + iterable unpacking

Serhiy Storchaka report at bugs.python.org
Wed May 1 05:23:10 EDT 2019


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

For the second case, you can use

a, *L[::2] = "abc"

For the first case this does not work, because an assignment can have only one starred expression.

Making the first case to work as you expected is breaking change. Currently

L[:], *rest = 'abcdef'

sets L to ['a'] and rest to ['b', 'c', 'd', 'e', 'f']. Consistent implementing of your idea would set L to ['a', 'b', 'c'] and rest to ['d', 'e', 'f'] (because len(L[:]) == 3 before assignment).

What is your use case? Why do you need such syntax?

----------
nosy: +serhiy.storchaka

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36761>
_______________________________________


More information about the Python-bugs-list mailing list