question about True values
John Salerno
johnjsal at NOSPAMgmail.com
Wed Oct 25 15:19:59 EDT 2006
Paul Rubin wrote:
> No. True and False are boolean values, where booleans are a different
> data type from strings, just like strings are different from integers.
>
> >>> if s:
> print 'hi'
>
> converts s to a boolean during evaluation.
Oh!!! I get it now! I was thinking that
if s
was the same as
if s == True
because I know sometimes you can write if statements this way (though
it's wordy). 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)
would be the same as
if (10 > 5) == True
because (10 > 5) does evaluate to "True".
More information about the Python-list
mailing list