weird behaviour of "0 in  is False"
sylvain.thenault at nospam.logilab.fr
Tue Nov 30 14:32:59 CET 2004
On Tue, 30 Nov 2004 14:18:30 +0100, Diez B. Roggisch wrote:
>>>>> 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.
yes, I forget to mention that it was the third expression which was
>>>>> (0 in l) is False
>>>>> 0 in l is False
> It seems to stem from a behaviour python exhibits in expressions like
> 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.
thanks, I had missed this part of the language reference !
Not yet found an misbehaviour in python... ;)
Sylvain Thénault LOGILAB, Paris (France).
http://www.logilab.com http://www.logilab.fr http://www.logilab.org
More information about the Python-list