Python evaluation order

Posted by d.m on Stack Overflow See other posts from Stack Overflow or by d.m
Published on 2010-03-16T08:07:31Z Indexed on 2010/03/16 8:16 UTC
Read the original article Hit count: 280

Filed under:

Here's the code, I don't quite understand, how does it work. Could anyone tell, is that an expected behavior?

$ipython

In [1]: 1 in [1] == True
Out[1]: False

In [2]: (1 in [1]) == True
Out[2]: True

In [3]: 1 in ([1] == True)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/dmedvinsky/projects/condo/condo/<ipython console> in <module>()

TypeError: argument of type 'bool' is not iterable

In [4]: from sys import version_info

In [5]: version_info
Out[5]: (2, 6, 4, 'final', 0)

© Stack Overflow or respective owner

Related posts about python