Defending the ternary operator

Andrew Koenig ark at
Sat Feb 8 20:23:53 CET 2003

Tim> C's || isn't Python's "or".  x || y in C is like Python's

Tim>     (x and 1) or (y and 1) or 0

Tim> That is, || always returns a little bool-like integer in C, regardless of
Tim> its operands' types.

...and in C++ it returns a bool.

Andrew Koenig, ark at,

More information about the Python-list mailing list