(PEP-308) Python's Conditional Selection Operators

Terry Reedy tjreedy at udel.edu
Sat Feb 15 22:07:45 EST 2003


"Steven Taschuk" <staschuk at telusplanet.net> wrote in message
news:mailman.1045325509.10547.python-list at python.org...
> Quoth Terry Reedy:
> > PYTHON'S CONDITIONAL SELECTION OPERATORS: 'AND' AND 'OR'
>
> An interesting discussion.
>
> > [...] For
> > efficiency, execution of the second operand can be conditional on
the
> > first not being dominant.  The possible problem is when execution
of b
> > has a side-effect that also becomes conditional.
>
> What is "the possible problem" to which you refer?  To me, the
> fact that the second operand's side-effects are conditional is one
> of the most desirable properties of these operators' definitions.

It is a _possible_ problem because someone who does not know about (or
forgets about) short-cut execution might end up with a subtle bug.

> > Selective 'and' and 'or' have an unusual combination of
properties.
> > [...] They are non-commutative [...] Both are associative [...]
>
> Also note these properties:
[snip]

Thank you for the additions.  My brain was boggled after I got as far
as I did.

Terry J. Reedy






More information about the Python-list mailing list