This questions stems from PEP 448 -- Additional Unpacking Generalizations and is present in Python 3.5 as far as I'm aware (and not back-ported to 2.x). Specifically, in the section Disadvantages, the following is noted:
Whilst
*elements, = iterablecauseselementsto be alist,elements = *iterable, causeselementsto be atuple. The reason for this may confuse people unfamiliar with the construct.
Which does indeed hold, for iterable = [1, 2, 3, 4], the first case yields a list:
>>> *elements, = iterable
>>> elements
[1, 2, 3, 4]
While for the second case a tuple is created:
>>> elements = *iterable,
>>> elements
(1, 2, 3, 4)
Being unfamiliar with the concept, I am confused. Can anyone explain this behavior? Does the starred expression act differently depending on the side it is on?