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

Terry Reedy tjreedy at udel.edu
Fri Feb 21 11:15:54 EST 2003


"Tim Peters" <tim.one at comcast.net> wrote in message
news:mailman.1045800478.31116.python-list at python.org...

> [Mike Orr]
> > Python has always been great in adding, not every feature,
> > but a few well-chosen features that have wide applicability.
>
> The perceived lack of which (wide applicability) being why Guido
rejected
> his implementation of conditionals last time around.  I can't say
I've seen
> many compelling use cases in this incarnation of the beast (and, no,
min and
> max aren't compelling -- although they would be if they weren't
built in
> already -- if "functions like that" were common, I'd expect to see
some
> examples other than min and max <wink>).

If Python did all looping by recursion, there would be many more
possible uses (though no more necessity) for a ternary conditional:

def fact(n): return n and n*fact(n-1) or 1
# needs a negative arg guard

def sum(seq): return (len(seq) or 0) and seq(-1) + sum(:-1)
# works better with head/tail linked list so no copying of tail

But Python does have for, while, map, filter, reduce, file.readlines,
(new) itertools, etc. in addition to min and max.

Terry J. Reedy






More information about the Python-list mailing list