# Question About Logic In Python

Fri Sep 23 02:09:21 CEST 2005

```Terry Hancock wrote:
> On Thursday 22 September 2005 12:26 pm, Ron Adam wrote:
>
>>Steve Holden wrote:
>>
>>>
>>>> >>> True * True
>>>>1                   # Why not return True here as well?
>>>>
>>>
>>>Why not return 42? Why not return a picture of a banana?
>>
>>My question still stands.  Could it be helpful if bools were preserved
>>in more cases than they are now?
>
>
> No.  "*" is "multiplication".
> The multiplication operator is undefined for boolean values. It only
> makes sense if they are interpreted as numbers. As it happens, both
> can be coerced to 1, so the result is 1*1. This makes perfect sense
> to me.

I'm not implying it doesn't make sense.  It does to me as well.  And it
would only make sense to return bools in this case if Python supported
boolean math.

If it did, coercion to ints (or floats) would still occur with mixed
types are used in expressions, but there are some situations where the
bool-bool results differ, so it's most likely an all or nothing move.

Both views are valid and there are benefits to both as well.

>>>>True and True
>
> True
>
> Also makes sense (and this is indeed what happens).

Only because True is the last value here. ;-)

> Cheers,
> Terry

Cheers,
Ron

```