Does anybody know the reasoning as to why the unary (*
) operator cannot be used in an expression involving iterators/lists/tuples?
Why is it only limite
This is not supported. Python 3 gives a better message (though Python 2 does not support *
in the left part of an assignment, afaik):
Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
>>> [1,2,3, *[4,5,6]]
File "", line 1
SyntaxError: can use starred expression only as assignment target
>>>
f(*[4,5,6])
is equivalent tof(4,5,6)
Function argument unfolding is a special case.