Empty string is False right?
John Machin
sjmachin at lexicon.net
Sat Jan 31 07:43:25 EST 2009
On Jan 31, 11:16 pm, AJ Ostergaard <a... at cubbyhole.net> wrote:
> Hi Ralf,
>
> Thanks for that but why:
>
> >>> '' and True
> ''
>
> Surely that should be False?!?
No, deliberately not. Read this for Python 3.0
http://docs.python.org/3.0/reference/expressions.html#boolean-operations
and/or this for Python 2.X
http://docs.python.org/reference/expressions.html#boolean-operations
[essentially the only difference in 3.0 is a change to the protocol
that allows a non-builtin object to say whether it is true or false]
More information about the Python-list
mailing list