(PEP-308) Python's Conditional Selection Operators

Terry Reedy tjreedy at udel.edu
Sun Feb 16 23:51:58 EST 2003


<snip more useless quibbles about my usage of the word 'standard' in
one of its standard meanings  (recursive pun intentional)>

To set the stage for my essay, I wrote: "Python's 'and' and 'or' are
not the standard versions:" and immediately explained the contrast
that I intended to explore and elucidate.

   In logic, math, and computing science, 'and' and 'or' have
well-known
   standard meanings as logical operators, either strict or
   domain-extended via operand coercion, and either conditional in
   execution or not.

   In Python, 'and' and 'or' are generalized as conditional selection
   operators (as explained in following sections), with some unusual
   properties.

Please notice: I said 'In logic, math, and computing science...".  As
to logic and math, the rest of my statement is obviously correct.  As
for computing science, I am rather sure of correctness there also.
Two (nonrandom) examples: Knuth, AoCP 1, 2nd ed, p 346, "operators of
symbolic logic (AND, OR ..."; Gries, Sci of Prog. p9 "five operators
are defined over values of type *Boolean*: ... and ... or ...".  If
someone believe that these two prominent computer scientists are in
the minority, let them present some counter-evidence.

I intentionally did *not* add 'computer languages' to that list.  I
know that in C (and I presume C++) and/or are extended conditional
logic operators, but I don't know or have forgotten about most
everything else.  I also know that language comparisons lead to
religious debates, which do not interest me and which I would prefer
to left out of.  Besides, I think most people think that it is
newcomers to Python, who know some logic, math, maybe some CS, with
maybe some experience in C, but typically not with Lisp, who have the
most trouble with and/or or or/and as conditional selection operators.
Part of the purpose of my essay is to suggest why they are confused
and how they might be less confused.

Also, I wrote 'standard', not 'Standard' (as in ASCII, ANSI, ISO,
Standard C, etc).  Nor did I hint at the existence of any 'L, M, and
SC Terminology Standards Committee'.  I would prefer that people read,
study, and respond to what I did write rather than criticize what I
intentionally did not write.

---
Gareth McCaughan wrote

> The way it looks to me is:
> Terry made a value judgement (objecting to Python's and/or
> because they're "not the standard versions");

Hogwash.  Read what I wrote and show me where I even *hint* at such an
objection (and I will revise it).  In point of fact, the person who
originally nitpicked 'standard' objects to what I write precisely
because I accept and use Python's definitions.

Terry J. Reedy






More information about the Python-list mailing list