Steven D'Aprano <steve+pyt...@pearwood.info> added the comment:

This is not a bug, "pass" is not an operator, it is not an expression, it is a 
statement and is only allowed in places where statements are allowed.

The if expression requires all three operands to be expressions.

Even if "pass" was permitted, what would it do? What would be the value of x 
after this assignment?

    x = 1 if False else pass

If you need x to be undefined, use an if statement:


    if False:
        # this block is not run
        x = 1

    # x is undefined here

----------
nosy: +steven.daprano
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue45456>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to