boolean true and false values.

Albert Hofkamp hat at se-46.wpa.wtb.tue.nl
Wed Jun 21 10:37:26 EDT 2000


On Wed, 14 Jun 2000 21:32:34 GMT, Thaddeus L. Olczyk <olczyk at interaccess.com> wrote:
>Does python have true and false values.
>I would like to do something like
>
>class A:
>     def _init_(self):
>           self.processed=false
>     def process(self):
>	self.processed=true
>
>at the moment I am using
>false=(1==0)
>true=(1==1)
>but would like something more elegant, or at least less sloppy.

I read a number of replies, but didn't read an answer that seems satisfactory.
I ran in the same problem, and was also not able to find a elegant solution.
Using 0 and 1 or `true` and None is not correct imho, there should be a native
way to use true and false for indicating boolean values.

Note that this is an advanced topic in the sense that beginning programmers
don't even realize that (1==2) is an expression with a value. On the other
hand, I use bool and its true and false values quite often in C++ rather than 0
and 1 which leaves way to much room for mistakes like assigning 2 to it.

Imho Python should have the data type boolean, with the values true and false.
Obviously, it can be build (or maybe already exists), but it would be real nice
if it would be a native data type.

Also, I am missing the data type 'set'. It can be faked with a dictionary, but it
is just not the same. Any one else got this problem ?

Albert
---
Look ma, windows without Windows !!



More information about the Python-list mailing list