Paul Rubin wrote:
> John Salerno <johnjsal at NOSPAMgmail.com> writes:
> > I'm a little confused. Why doesn't s evaluate to True in the first
> > part, but it does in the second? Is the first statement something
> > different?
>> 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. That is, it's the same as
>> if bool(s): print 'hi'
>> bool(s) is a function that converts s to a bool. If s is a string,
> bool(s) is true if s is nonempty, false otherwise.
>> A comparable thing with integers: suppose
>> x = 3.1
>> then "x == 3" is false, but "int(x) == 3" is true.
But then why is 3.0 == 3 true? They are different types.