John Salerno <[EMAIL PROTECTED]> 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. -- http://mail.python.org/mailman/listinfo/python-list