question of style
steve at REMOVE-THIS-cybersource.com.au
Sun Jul 5 18:13:30 CEST 2009
On Sun, 05 Jul 2009 11:37:49 +0000, Lie Ryan wrote:
> Neither python's `if` nor `if` in formal logic is about testing True vs.
> False. `if` in python and formal logic receives a statement. The
> statement must be evaluatable to True or False, but does not have to be
> True or False themselves. It just happens that True evaluates to True
> and False evaluates to False.
I think your explanation is a little confused, or at least confusing.
`if` implements a two-way branch. Some languages, like Pascal and Java,
requires the switch value to take one of two specific enumerable values
conventionally spelled TRUE and FALSE (modulo variations in case).
Other languages don't require specific enumerable values, and instead
accept (e.g.) any integer, or any object, with rules for how to interpret
such values in such a context. Forth, for example, branches according to
whether the word on the stack is zero or non-zero: "nothing" or
"something". Lisp branches according to empty list or non-empty list:
"nothing" or "something" again.
Other languages, like Ruby, have less intuitive rules. That's their
More information about the Python-list