"Paul Robson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED]
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 ?

It's not an error. As one of the first responders said, check the language definition. That defines both 'in' and 'is' as equality operators, and defines exactly what a chain of equality operators means.

In this case, it means:

(0 in l) and (l is False)

The and short circuits, giving the result of False without
ever doing the final comparison.

Granted, that's not exactly obvious...

John Roth






-- http://mail.python.org/mailman/listinfo/python-list

Reply via email to