question about True values

J. Clifford Dyer webmaster at cacradicalgrace.org
Sat Oct 28 22:46:34 CEST 2006


Georg Brandl wrote:
> J. Clifford Dyer wrote:
> 
>>  >>> (1 > 0) < 1
>> False
>>  >>> 1 > 0 < 1
>> True
>>  >>> 1 > (0 < 1)
>> False
>>  >>> 10 > (0 < 1)
>> True
> 
> I hope you know why this works the way it does.
> 
> Georg

Yes, I do understand why it works.  I couldn't have crafted it if I 
didn't, but my point is that the reason why it works is not explainable 
if you believe that you are dealing with booleans.  It's only 
explainable if you recognize that you are actually dealing with 
integers, and specifically, 1 and 0.  So the something/nothing dichotomy 
combined with an understanding of what the comparison operation REALLY 
does (yield a 1 or a 0) helps you understand where your result came 
from, while thinking in terms of true/false will mislead you.






More information about the Python-list mailing list