New issue
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
Assignment expression in assert causes SyntaxError #84090
Comments
Assignment expression in assert causes SyntaxError Minimal case:
Error:
Workaround:
My use case:
|
I believe this is by design, as is the same restriction on statement-level assignment expressions. And if requiring parens discourages the use of assignment expressions in asserts, I think that's a good thing. Why not just use the workaround you've already identified? |
if this is by design i'm fine with somebody closing this issue. i've not found mention of such case in pep so i though it's not by design. workaraund does not look as cool because of parentheses. again, if this is "as intended" i'm fine with closing issue. |
It's good that this syntax is rejected: it looks like a typo (assert var == None). Moreover, it's part of of the PEP-572 design. Python works as expected, I suggest to close the issue as not a bug. |
I'm going to close this, since I can't imagine this restriction being relaxed. |
ok |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: