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

that should be clear - 0 in False can't work.

>>>> (0 in l) is False
> True
>>>> 0 in l is False
> False

It seems to stem from a behaviour python exhibits in expressions like this:

3 > 2  > 1

This yields True, while

(3 > 2 ) > 1

yields false. Chaining of operators gets translated like this:

3 > 2 and 2 > 1

Look in section 5.9 of the language reference.

Then your expression gets translated to:

0 in l and l is False

which yields False of course.


-- 
Regards,

Diez B. Roggisch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to