Most compact "X if X else Y" idiom

Steven D'Aprano steve at
Sun Oct 12 07:35:54 CEST 2008

On Sun, 12 Oct 2008 05:30:33 +0000, Steven D'Aprano wrote:

> Use short-circuit Booleans:
> y = x or "blah"

Except of course you don't use x, you use the complex expression.

y = (some complex expression) or "blah"

Sorry for the itchy posting finger.


More information about the Python-list mailing list