question about True values
Steven D'Aprano
steve at REMOVE.THIS.cybersource.com.au
Thu Oct 26 10:51:54 EDT 2006
On Wed, 25 Oct 2006 19:19:59 +0000, John Salerno wrote:
> Oh!!! I get it now! I was thinking that
>
> if s
>
> was the same as
>
> if s == True
No. But you know that now :)
> because I know sometimes you can write if statements this way (though
> it's wordy).
You can, but shouldn't.
> But what I didn't realize was that in the cases I was
> thinking of, 's' was an expression that evaluated to a boolean value,
> not an actual value of some other type!
>
> So I suppose
>
> if (10 > 5)
Is the same as:
if True
because (10 > 5) evaluates as True.
> would be the same as
>
> if (10 > 5) == True
Did you mean
if (10 > 5) == True == True
or
if (10 > 5) == True == True == True
or even
if (10 > 5) == True == True == True == True
I hope you see my point now.
> because (10 > 5) does evaluate to "True".
I think it is a good time to remind people of some extremely well-thought
out opposition to the introduction of bools to Python from Laura Creighton:
http://mail.python.org/pipermail/python-list/2002-April/095878.html
She lost the debate, Guido had the final word and Python now has bools.
Take particular note of her description of Python distinguishing between
Something ("cat", 4, [0, 1, 2] etc) and Nothing ("", 0, [] etc).
--
Steven.
More information about the Python-list
mailing list