A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/296552.html below:

Question About Logic In Python

Question About Logic In Python Question About Logic In PythonTerry Hancock hancock at anansispaceworks.com
Thu Sep 22 18:08:17 EDT 2005
On Thursday 22 September 2005 12:26 pm, Ron Adam wrote:
> Steve Holden wrote:
> > Ron Adam 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.

>>> True and True
True

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

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4