PEP 308: "then" "else" for deprecating "and" "or" side effects

Christian Tismer tismer at
Fri Feb 14 15:25:03 CET 2003

Erik Max Francis wrote:
> Christian Tismer wrote:

[and or]

>>"and" and "or" are behaving like logical operators.
>>They happen to do this by not providing a plain
>>truth value, but by promoting one of their operands.
> They _are_ logical operators.  They just do their logical by returning
> one of the objects, rather than a strict Boolean.  Other languages do
> this, like Lisp; there's nothing inherently wrong with it.  It's also
> way too entrenched to change now.  It's an example of a feature that I
> don't often rely on, but even I, a champion of the Booleans PEP,
> wouldn't think to change their behavior now.

That's fine with me. Note that I do not say that we
should change and and or (ignore my words about
future deprecation). Instead, we should not
abuse them in a way that has nothing to do with an
"and", like the "(a and [b] or [c])[0])" tricks
or the proposed {} escape. These are tricks to make
them behave differently.
I only propose to make these uses explicit
by using "then" and "else" instead.

Christian Tismer             :^)   <mailto:tismer at>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship*
14109 Berlin                 :     PGP key ->
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?

More information about the Python-list mailing list