Instead the accepted, idiomatic Python way of writing this was to use
short-circuit booleans:
result = condition and x or y
However this idiom is buggy! If x is a false-value (say, 0) then result
gets set to y no matter what the value of condition.
This is only a bug if one expects otherwise.
This buggy idiom survived many years of Python development, missed by
virtually everyone.
The last statement is false. The hazard of using and/or was well-known
back in '97 or so when I discovered or learned it and I believe it was
mentioned in the FAQ entry on the subject. The new alternative has the
hazard that the condition and if-branch must be written and read in a
backwards order. I consider that buggy and do not use it for that reason.
Terry Jan Reedy
--
http://mail.python.org/mailman/listinfo/python-list