Simple question

Peter Otten __peter__ at web.de
Sat Aug 23 09:26:40 EDT 2014


explodeandroid at gmail.com wrote:

> Can some one explain why this happens:
> True, False = False, True
> print True, False
> False True

You are using Python 2 where True/False are names that can be rebound. This 
is for backwards compatibility as Python didn't always have booleans and 
people made their own with

True = 1
False = 0

or similar.

In Python 3 True and False are keywords:

>>> True = False
  File "<stdin>", line 1
SyntaxError: can't assign to keyword





More information about the Python-list mailing list