[Tutor] i know this should be easy
nephish at xit.net
Wed Aug 17 16:16:50 CEST 2005
Kent Johnson wrote:
>>i have a simple question.
>>if something returns a true or false, how do i test for it with an if
>>i am using pygtk with a toggle button that returns TRUE if checked and
>>FALSE if not.
>>do i need quotes around the TRUE / FALSE or should i use 1 and 0?
>>Auto_Tog = self.AutoCheckRaw.get_active()
>>if str(AddDay_Tog)== '1':
>> do so and so.
>I'm not sure what you mean by TRUE and FALSE but you can most likely just test it directly:
>Auto_Tog = self.AutoCheckRaw.get_active()
> do so and so.
>In the context of Boolean operations, and also when expressions are used by control flow statements, the following values are interpreted as false: None, numeric zero of all types, empty sequences (strings, tuples and lists), and empty mappings (dictionaries). All other values are interpreted as true.
>So any reasonable values for TRUE and FALSE will work fine.
>Tutor maillist - Tutor at python.org
cool. thanks much !
More information about the Tutor