擅长:python、mysql、java
<p>因为,正如替代名称(命名表达式)所示,<a href="https://www.python.org/dev/peps/pep-0572/" rel="noreferrer">the left hand side of the walrus operator is to be a ^{<cd1>}</a>。因此,根据定义,您的问题中提到的表达式以及(例如)函数调用不允许在此表单中分配</p>
<p>文件还规定:</p>
<blockquote>
<p>Single assignment targets other than a single <code>NAME</code> are <strong>not</strong> supported</p>
</blockquote>
<p>为了进一步说明这个论点,可以注意到,如果表达式为^{<cd2>,则cPython显式地<a href="https://github.com/python/cpython/blob/87d3b9db4ade1aa100ee6f065082cb7e85b8992f/Python/ast.c#L1855" rel="noreferrer">checks</a>:</p>
<pre><code>if (target->kind != Name_kind) {
const char *expr_name = get_expr_name(target);
if (expr_name != NULL) {
ast_error(c, n, "cannot use assignment expressions with %s", expr_name);
}
return NULL;
}
</code></pre>