First, the starred name may match just a single item, but is always assigned a list:
seq = [1, 2, 3, 4]
a, b, c, *d = seq
print(a, b, c, d)
Second, if there is nothing left to match the starred name, it is assigned an empty list, regardless of where it appears.
In the following, a, b, c, and d have matched every item in the sequence, and Python assigns e an empty list:
seq = [1, 2, 3, 4] a, b, c, d, *e = seq # w w w . j ava 2 s . co m print(a, b, c, d, e) a, b, *e, c, d = seq print(a, b, c, d, e)
Errors can be triggered
seq = [1, 2, 3, 4] a, *b, c, *d = seq #SyntaxError: two starred expressions in assignment a, b = seq #ValueError: too many values to unpack (expected 2) *a = seq #SyntaxError: starred assignment target must be in a list or tuple *a, = seq a #[1, 2, 3, 4]