0 == False but [] != False?

Dan Bishop danb_83 at yahoo.com
Thu May 24 19:02:20 EDT 2007


On May 24, 1:59 am, Tim Roberts <t... at probo.com> wrote:
...
> False is just a constant.  0, (), '', [], and False are all constants that
> happen to evaluate to a false value in a Boolean context, but they are not
> all the same.
>
> As a general rule, I've found code like "if x == False" to be a bad idea in
> ANY language.

I have a job as a C++ programmer, and they make us write it like that,
apparently because the ! operator is hard to see.  But "if (x ==
TRUE)" is discouraged.




More information about the Python-list mailing list