weird behaviour of "0 in [] is False"

Paul Robson autismuk at autismuk.muralichucks.freeserve.co.uk
Tue Nov 30 09:51:01 EST 2004


Sylvain Thenault wrote:

>>>> l = []
>>>> 0 in (l is False)

(l is False) is not a tuple or list, it's a boolean value.

> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: iterable argument required
>>>> (0 in l) is False
> True

0 in l is False becuase l is empty, so it's False is False which is true,
(except in Intercal probably and Visual C++)

>>>> 0 in l is False
> False

l is False is False because l is not the value false though it has a false
value (err.....)

Okay. 

l != False because it's not the displayed value false

but if not l would evaluated to true because [] is a false equivalent.

0 in False .... okay.... this should be an error ..... something to do with
the equivalence confusion of what False is ?






More information about the Python-list mailing list