John Roth newsgroups at
Mon Aug 4 05:12:52 CEST 2003

"Daniel Klein" <danielk at> wrote in message
news:fucrivcvd2mel7k51ij1hktb55gqnmk9ic at
> In Python 2.2 I use to have
> true = (1 == 1)
> false = not true
> This was at the recommendation of someone on this list some time ago.
> The reason (if I remember correctly) was that setting
> true = 1
> false = 0
> were not true booleans.

There were no true booleans in 2.2 and earlier. Whoever recommended
that didn't know what he was talking about. There was no difference.

> Now the expression (1 == 1) returns 'True', and caused a bug in my
> code. So my question is what is the proper method for setting booleans
> in 2.3?

I presume what broke your code was depending on the return from
either str() or repr(), or the % operator. That was, unfortunately, one
of the incompatibilites between 2.2 and 2.3.

In 2.3, Boolean is a subtype of Int, and has two values: True and False.
Both of these are built in constants, so just use them. That's what they're
for. For most purposes, the are the same as 1 and 0, except for what they
return from str() and repr(), and how they get formatted with %.

John Roth

> Really confused,
> Daniel Klein

More information about the Python-list mailing list