On Sat, Jul 12, 2008 at 6:03 PM, Dick Moores <[EMAIL PROTECTED]> wrote:
> At 01:34 PM 7/12/2008, Kent Johnson wrote:

>> In [2]: assert(False, "Asserted false")
>>
>> This is "assert condition" where the condition is a tuple with two
>> elements, hence true so there is no output.
>
> In [13]: assert(3 < 2 , "qwerty")
>
> In [14]:
>
> I don't understand that logic. Could you unpack it for me?

(False, "Asserted false") is a tuple containing two values, False and
"Asserted false".

"assert x" evaluates x as a boolean; if it evaluates to False, the
assertion is raised. A tuple with two elements will always evaluate to
True so the assertion is never raised.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to