Empty string is False right?

Grant Edwards grante at visi.com
Sat Jan 31 09:15:58 EST 2009


On 2009-01-31, Vlastimil Brom <vlastimil.brom at gmail.com> wrote:
> 2009/1/31 AJ Ostergaard <aj at cubbyhole.net>:
>> Hi Ralf,
>>
>> Thanks for that but why:
>>
>>>>> '' and True
>> ''
>>
>> Surely that should be False?!?
>>
>> Regards,
>> AJ
>>
>>
> see the docs:
> http://docs.python.org/reference/expressions.html#boolean-operations
>
> "The expression x and y first evaluates x; if x is false,

But that doesn't mean "x is False" in the strict Python
expression sense of the phrase.  It means if bool(x) is False
(or something reasonably close to that).

> its value is returned; otherwise, y is evaluated and the
> resulting value is returned."

-- 
Grant




More information about the Python-list mailing list