On Sat, 28 Oct 2006 03:13:42 +0100, Steve Holden wrote:
>> 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". Python bools really are subclassed from ints: >>> issubclass(bool, int) True They are ints wearing a Boolean hat. This was a controversial compromise. >> >>> (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. Run through the expressions by hand: (1 > 0) < 1 True < 1 False The mere fact that you can compare bools with ints demonstrates that Python bools aren't "real" Booleans. >> 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 Cliff is making a point about semantics, and he's absolutely correct about it, although it is irrelevant since we're talking about two-value logic not semantics. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list