At 06:38 PM 3/10/05 -0800, Bill Janssen wrote:
Guido,

I think there should be a PEP.  For instance, I think I'd want them to be:

def any(S):
  for x in S:
    if x:
      return x
  return S[-1]

def all(S):
  for x in S:
    if not x:
      return x
  return S[-1]

Or perhaps these should be called "first" and "last".

More precisely (since "S" might be an iterator, or empty):

def any(S):
    x = False
    for x in S:
        if x: break
    return x

def all(S):
    x = True
    for x in S:
        if not x: break
    return x

However, "first" and "last" don't make sense to me as names. First what? Last what? Actually, "any" and "all" don't make that much sense to me either. I find myself wanting to call them "or" and "and", or maybe "or_iter" and "and_iter". Or perhaps "until_false" or "until_true". Nah, the and/or names make more sense, as they exactly match the behavior of the corresponding logical operators, if you could call them as a function. At least, if they took *args anyway.


_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to