PEP 289: universal and existential operators

Jeremy Fincher tweedgeezer at hotmail.com
Wed Nov 5 09:46:00 EST 2003


austin at smartobject.biz (Jess Austin) wrote in message news:<b3ad1da7.0311050138.433f3478 at posting.google.com>...
> This is great.  I'd like to request that alltrue() and anytrue() be
> renamed forall() and exists(), repsectively.

While these are the mathematical names, I've almost always seen them
named "all" and "any" in the various (mostly functional) programming
languages I've seen them in.

Exists() also has the problem that to less mathematically-minded
people (or Perl programmers :)) it isn't exactly clear what it's
checking for.  Certainly, one would expect a generator expressions
like "x%y for y in xrange(2, math.sqrt(x))" to "exist," since we can
see it in the code and look at it with our own eyes.

I think these names also read somewhat more clearly:

# Check if someone is yelling:
if all(str.isupper, line.split()):
  print "Must be a flamewar."

and:

# Check if someone yelled at all:
if any(str.isupper, line.split()):
  print "Someone yelled."

I believe both these examples are more easily readable with "all" and
"any" than they would be with "forall" and "exists."

Jeremy




More information about the Python-list mailing list