Empty string is False right?

AJ Ostergaard aj at cubbyhole.net
Sat Jan 31 07:36:03 EST 2009


I'm not suggesting it's not operating as advertised - I'm suggesting  
the 'advertising' is slightly sguiffy if you catch my drift. I guess  
it's just me that finds it slightly counter intuitive. Surely  
intuitively the expression is "and" and therefore should always return  
a boolean?

I'll shut up now. ;)

AJ


On 31 Jan 2009, at 12:27, Vlastimil Brom 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, its value is
> returned; otherwise, y is evaluated and the resulting value is
> returned."
>
> hth,
>  vbr




More information about the Python-list mailing list