Geobird writes: > @ Ulrich : Tx > @ Rebert : Appreciate your interpretation. > It made me think about ternary operation . Say > >>> (a > b) and x or y > > Are all ternary operations prone to ...( in your words ) > > It exploits short-circuit evaluation > >(http://en.wikipedia.org/wiki/Short-circuit_evaluation ). This is > >stunt coding / code golf; no one should actually write factorial > like > >that.
The purpose of a conditional expression is to select one branch of computation and avoid another. Other ternary operations might well use the values of all three arguments. (I agree that no one should write factorial like that, except as a joke. I have nothing against (x if (a > b) else y). The trick with and and or was used before Python had an actual conditional expression.) -- http://mail.python.org/mailman/listinfo/python-list