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/325706.html below:

Question About Logic In Python

Question About Logic In Python Question About Logic In PythonSteven D'Aprano steve at REMOVETHIScyber.com.au
Tue Sep 20 19:03:00 EDT 2005
On Tue, 20 Sep 2005 03:03:15 +0000, Ron Adam wrote:

> Steven D'Aprano wrote:
>> Are there actually any usage cases for *needing* a Boolean value? Any
>> object can be used for truth testing, eg:

[snip]

> Of course if any of the default False or True conditions are 
> inconsistent with the logic you use, you need to do explicit truth testing.

[snip]

> So..
> 
>     bool(a and b) * value
> 
> Would return value or zero, which is usually what I want when I do this 
> type of expression.

That's all very interesting, and valuable advice for somebody who doesn't
understand how Python's logical operators work, but the question is, when
would you actually want that type of expression?

In practice, how often do you really care that your truth values have the
specific values 0 and 1 rather than anything false and anything true? In
what circumstances?



-- 
Steven.


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