[Tutor] Another assert() question

Kent Johnson kent37 at tds.net
Sun Jul 13 04:39:14 CEST 2008

On Sat, Jul 12, 2008 at 6:03 PM, Dick Moores <rdm at rcblue.com> 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.


More information about the Tutor mailing list