[Tutor] Another assert() question

Marc Tompkins marc.tompkins at gmail.com
Sun Jul 13 05:46:14 CEST 2008


On Sat, Jul 12, 2008 at 8:10 PM, Dick Moores <rdm at rcblue.com> wrote:

> But why will a tuple with two elements will always evaluate to
> True?
>
> In [2]: (3,5) == True
> Out[2]: False
> In [3]: ("qwerty", "asdfg") == True
> Out[3]: False
> In [4]:
>
>
The value formally known as True is only one member of the set of things
that don't evaluate to False...  Confused yet?

Anyway, this might make it a bit clearer:

>>> (3,2) == True
False
>>> if (3,2): print "Tru, dat"
...
Tru, dat
>>>

In other words, "(3,2)" isn't exactly the same as "True" - but it doesn't
evaluate to False, either, so it's true.

It's a bit like arguments about the nature of Good and Evil, I'd say.
-- 
www.fsrtechnologies.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080712/c0f6c208/attachment-0001.htm>


More information about the Tutor mailing list