Defending the ternary operator

Andrew Koenig ark at research.att.com
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 research.att.com, http://www.research.att.com/info/ark




More information about the Python-list mailing list