Is it guaranteed that False == 0 and True == 1 in Python?

Posted by EOL on Stack Overflow See other posts from Stack Overflow or by EOL
Published on 2010-05-04T09:03:30Z Indexed on 2010/05/04 9:08 UTC
Read the original article Hit count: 236

Filed under:
|
|

Is it guaranteed that False == 0 and True == 1, in Python? For instance, is it in any way guaranteed that the following code will always produce the same results, whatever the version of Python (existing and in the foreseeable future)?

0 == False  # True
1 == True   # True
['zero', 'one'][False]  # is 'zero'

Any reference to the official documentation would be much appreciated! Other comments would be appreciated too… :)

© Stack Overflow or respective owner

Related posts about python

Related posts about true