From a language design point of view, nothing is wrong. As another poster mentioned, it's even the preferred way. I would even ask you why do you imply that being a ternary is wrong?
From a readability/maintainability point of view, things are a bit more databable. On one hand, if you are going to have a lot of casual, non-Python readers/maintainers, this construct (as opposed to if not x: x= C
) could be much less readable. On the other hand, your program will most probably contain many other (and much deeper) Pythonisms. You have a right to expect a minimum of knowledge from your "readers".
From a performance point of view, x
being a variable both forms are optimizable (if not effectively optimized) by the different implementations into the same code. Meaning no difference in these terms.
UPDATE:
I didn't know Guido's opinions on the subject cited by @Edward. I'm glad he agrees with me. Or I with him. But he was absolutely right about introducing the ternary operator, as it is much clearer than alternatives like x= (x,C)[not x]
or x= x or C
, which had been used (and promoted) by many early Python programmers with a C background (and perhaps also as a "cool", differentiating thing). BTW, both are generally correct (depending of the exact semantics intended).