True inconsistency in Python

Ben Finney bignose-hates-spam at and-benfinney-does-too.id.au
Thu Nov 13 00:27:25 EST 2003


On Wed, 12 Nov 2003 19:42:27 -0800, Scott Chapman wrote:
> There seems to be an inconsistency here:

Yes.  The inconsistency is in expecting all Boolean truths to be the
same value.

The object True will evaluate as a Boolean truth.  The object False will
not evaluate as a Boolean truth.  This doesn't mean that there are no
other values that will or won't evaluate as Boolean truth.

You many want to read the PEP that led to the creation of the 'bool'
type (and True and False objects):

    <http://www.python.org/peps/pep-0285.html>

In short:  Testing the Boolean truth of an expression is done with 'if',
not with value-comparison operators.

-- 
 \       "bash awk grep perl sed, df du, du-du du-du, vi troff su fsck |
  `\                  rm * halt LART LART LART!"  -- The Swedish BOFH, |
_o__)                                            alt.sysadmin.recovery |
Ben Finney <http://bignose.squidly.org/>




More information about the Python-list mailing list