boolean true and false values.

xtian xtianNOxtSPAM at hyperactive.co.nz.invalid
Wed Jun 14 23:51:03 EDT 2000


"Rainer Deyke" <root at rainerdeyke.com> wrote:
>Thaddeus L. Olczyk <olczyk at interaccess.com> wrote in message
>news:3947f922.425016156 at nntp.interaccess.com...
>> 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.
>
>false = 0
>true = 1
>

This is a bit risky, depending on that for which you'll be using
it - there are a lot of other expressions that evaluate to false
but not to zero, as Peter was illustrating (including user
defined objects, if the author has set it up that way).

If you've defined false, you might be trying to use checks like

  if (expression) == false:
    do_stuff()

when you should probably be doing

  if not expression:
    do_stuff()


Of course, if you're just using them for parameters or some
such, then I'll be quiet.

Xtian


* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!




More information about the Python-list mailing list