I do see how mapping to Truth/Falsehood is more natural, and I do 
believe that one of the great things about python is that it feels 
natural in so many ways, and hence makes it easy to produce code, but 
the one thing that Ms. Creighton points out that I can't get past is 
that Python, even with its bool type, *still* evaluates somethingness 
and nothingness, and True and False are just numbers with hats on.

 >>> True + 3
4
 >>> bool(True-1)
False
 >>> bool(True-2)
True
 >>> (10 > 5) + (10 < 5)
1

So when you say

 >>>if 10 > 5:
...     print "Yes!"

Python is not evaluating the truth of the matter, but, as Ms. Creighton 
would say, the "somethingness" of that which 10 > 5 evaluates to.  (1 
aka True)

Furthermore, how do you explain this bizarreness in terms of "Truth" and 
"Falsehood?"  You have to go back to the fact that True=1 and that 
REALLY, Python is dealing with somethingness and nothingness.  It might 
not be as direct a mental connection as True/False, but it is certainly 
a more accurate one for understanding how Python works.

 >>> (1 > 0) < 1
False
 >>> 1 > 0 < 1
True
 >>> 1 > (0 < 1)
False
 >>> 10 > (0 < 1)
True

Finally, while True/False is a good mental mapping for numeric 
comparisons, take the following:

 >>> if "Cliff is a pillar of the open source community":
...     print "thank you"
... else:
...     print "bugger off"

bugger off

Clearly this is not true.  (Google Cliff/Dyer open source: only 11 
hits.), but the string is *something* so the if block gets evaluated.

Cheers,
Cliff
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to