#306 Spurious "conditional statement with a constant value"?

0.8.18
open
nobody
None
5
2012-02-11
2012-02-11
Kevin Whitefoot
No

Pychecker issues this warning:

Using a conditional statement with a constant value (create)

for this statement:

"action:" + ((exists and "create") or
((not exists) and "delete"))])

To me, this expression seems to be idiomatic Python using the fact that Python returns the last evaluated item from a logical expression. Its purpose is simply to return either "action:create" or "action:delete" depending on the value of exists, perhaps not the best idiom but not as far as I can see either wrong or especially un-Pythonic.

What exactly is the warning trying to say?

Of course the warning was useful as it made me reconsider and now I have:

"action:" + (exists and "create" or "delete")

which is more Pythonic I think and also does not trigger any warnings.

However, the question remains: what does the warning really mean?

Discussion