J. Clifford Dyer wrote:
> 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!"
> 
Seems pretty clear to me that the situations you discuss above involve 
numeric coercions of a Boolean value.

> 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)
> 
  >>> type(10>5)
<type 'bool'>
  >>>

It does seem that there is a specific type associated with the result of 
a comparison, even though you would really like to to be "a number with 
a hat on".

> 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
> 
I have no idea what you think that you are demonstrating here.

> 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.
> 
  >>> if "The above example was bollocks":
  ...   print "You don't know what you are talking about"
  ... else:
  ...   print "Sorry: of course you are perfectly correct"
  ...
You don't know what you are talking about
  >>>

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to