PEP-308 a "simplicity-first" alternative

Erik Max Francis max at alcyone.com
Fri Feb 14 00:48:25 EST 2003


Bengt Richter wrote:

> I take it think that Python's and/or semantics was a design mistake.
> Perhaps so ;-)

There is nothing wrong with Python's `and' and `or' semantics; they're
very similar in functionality to those used in Lisp, for instance. 
However, the use of the _idiom_ combining the two in order to attempt to
the effect of a conditional operator -- `C and x or y' -- is idiomatic,
unreadable, and _wrong_.  There are ways to fix it (with single-element
lists or lambdas) that make it not wrong, but even more idiomatic and
unreadable.  These aren't good solutions.

What PEP 308 seeks to find is a _conditional operator_ that stands on
its own and is something the community can live with.  Any approaches
which start by repairing the and/or idiom may fix the problem with it
being wrong, but can't fix the problems with it being idiomatic and
unreadable.

For that reason, your `C and {x} or y' suggestion is simply more
idiomatic and unreadable, for the reasons that I've stated several times
by now.  The problem is the horrible and/or idiom; if you're going to
fix it, it should be fixing it by replacing it, not making it _more_
idiomatic.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ The average dog is a nicer person than the average person.
\__/ Andrew A. Rooney
    Python chess module / http://www.alcyone.com/pyos/chess/
 A chess game adjudicator in Python.




More information about the Python-list mailing list