[issue43055] Inconsistent behaviour when using walrus operator with 'and'/'or'
Eric V. Smith
report at bugs.python.org
Thu Jan 28 08:30:40 EST 2021
Eric V. Smith <eric at trueblade.com> added the comment:
I think this is pretty clearly the intended semantics. In your first example, what do you propose "print(x)" would produce? Consider:
if False and (x:=input()) != '':
pass
else:
print(x)
We cannot change the semantics to now call input(), or any function with side effects, just to do the assignment to x.
----------
nosy: +eric.smith
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43055>
_______________________________________
More information about the Python-bugs-list
mailing list