Eric V. Smith added the comment:
I'm going to close this. The short circuit evaluation of and/or expressions is
already documented, and this behavior follows directly from that.
--
resolution: -> not a bug
stage: -> resolved
status: open -> closed
Eric V. Smith 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
New submission from Aman Anifer :
Using the walrus operator (:=) alongside 'and'/'or' shows inconsistent
behaviour which changes with the order of given conditions.
For example:
if(False and (x := 0)<1):
print("Yes")
else:
print(x)
Gives the error that 'NameError: name 'x' is not