What case can `starred_expression` be used on the right side of =?

The doc says starred_expression can be used on the right side of = as shown below:

But starred_expression cannot be used on the right side of = as shown below:

v1, v2, v3 = *[0, 1, 2, 3, 4]

print(v1, v2, v3)
# SyntaxError: can't use starred expression here

Instead, starred_expression can be used on the left side of = even the doc doesn’t say starred_expression can be used on the left side of = as shown below:

 v1, *v2, v3 = [0, 1, 2, 3, 4]

print(v1, v2, v3)
# 0 [1, 2, 3] 4

So, what case can starred_expression be used on the right side of =?

In addition, yield_expression can be used on the right side of = in a generator as shown below:

def func():
    v = yield 'Hello'
    print(v)

gen = func()

next(gen)
# 'Hello'
  • The specific grammar snippet you linked doesn’t represent the real grammar. A closer approximation is in 10. Full Grammar specification — Python 3.13.7 documentation
  • That grammar uses star_expressions on the right-hand-side of assignments, which includes *tuple, value as well as *tuple. The later is filtered out via later semantic parsing instead of being rejected early at a syntax level. Why? Probably to reduce complexity of the parser which otherwise would have to consider even more cases.