On Mar 6, 2007, at 11:03 AM, Alan Gauld wrote: > It's doing the latter and since anything that's not 'empty' in > Python evaluates to true we wind up checking whether > true == (item in word) > > So if the item is in word we get true == true which is true. > > HTH,
Sorry, but this still doesn't make sense to me. >>> x=('i' in 'i') >>> x True >>> y='i' >>> x==y False I understand that anything that's not 'empty' or zero evaluates to True *when cast as a Boolean* by the operation in question: >>> if y: print "It's True!" ... It's True! But the == operator doesn't cast its operands as Booleans; it merely *returns* a Boolean. Or is the point that in the original case the == operator *is* casting item to Boolean because it's comparing it with another Boolean? That's kind of strange, especially considering that in my example above, it *didn't* do that. I still don't understand what's going on. :) -- -dave---------------------------------------------------------------- Science arose from poetry... when times change the two can meet again on a higher level as friends. -Göthe _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor