| |
comp.lang.python |
>>>> 0 == False > But, I know I can use [] to represent False as in >>>> if not []: print 'empty' > But then doing the following gives a surprising (to me!) result >>>> [] == False > Could anybody point out why this is the case? if x: is not the same thing as if x == True: it's the same as if bool(x): So a more meaningful comparison of your two tests are: >>> bool(0) == bool(False) --
> This is a slightly naive question, but I know that 0 can be used to
> represent False. So
> True
> ...
> empty
> False
False" are not the same thing.
...
...
...
True
>>> bool([]) == bool(False)
True
Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM, Y!M erikmaxfrancis
Woman was God's _second_ mistake.
-- Friedrich Nietzsche