We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the code is error
a = 1 b = 2 c = [111, 22] a, b = *c # Unpack operation is not allowed in this context
I don't understand why this a, b = *c statement is wrong?
a, b = *c
about assigement expression doc link: https://docs.python.org/3.13/reference/simple_stmts.html#assignment-statements
we have the rules
assignment_stmt ::= (target_list "=")+ (starred_expression | yield_expression) target_list ::= target ("," target)* [","] target ::= identifier | "(" [target_list] ")" | "[" [target_list] "]" | attributeref | subscription | slicing | "*" target
the assignment_stmt RHS is a starred_expression
I'm still a beginner in python, Now I think the *c is a starred_expression
*c
because
about starred_expression doc link: https://docs.python.org/3.13/reference/expressions.html#grammar-token-python-grammar-starred_expression
we have the rules:
starred_expression ::= ["*"] or_expr
c Is a identifier or_expr → xor_expr → and_expr → shift_expr → a_expr → m_expr → u_expr → power → primary → atom → identifier
The text was updated successfully, but these errors were encountered:
You can use this instead:
a, b = c
Sorry, something went wrong.
No branches or pull requests
Documentation
the code is error
I don't understand why this
a, b = *c
statement is wrong?about assigement expression doc link: https://docs.python.org/3.13/reference/simple_stmts.html#assignment-statements
we have the rules
the assignment_stmt RHS is a starred_expression
I'm still a beginner in python, Now I think the
*c
is a starred_expressionbecause
about starred_expression doc link: https://docs.python.org/3.13/reference/expressions.html#grammar-token-python-grammar-starred_expression
we have the rules:
c Is a identifier
or_expr → xor_expr → and_expr → shift_expr → a_expr → m_expr → u_expr → power → primary → atom → identifier
The text was updated successfully, but these errors were encountered: