"Steve R. Hastings" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > So, Python 2.5 will have new any() and all() functions. > http://www.python.org/dev/peps/pep-0356/ > > > any(seq) returns True if any value in seq evaluates true, False otherwise. > > all(seq) returns True if all values in seq evaluate true, False otherwise. > > I have a question: what should these functions return when seq is an empty > list? > Here is my attempt at a more formal approach to this question, rather than just using our intuition. Unfortunately, following this process proves my earlier post to be wrong, but, oh well...
Consider two sets A and B where A+B is the union of the two sets. if any(A+B) = True -> any(A) or any(B) = True but we cannot assert either any(A)=True or any(B)=True. if any(A+B) = False -> any(A) = False and any(B) = False. if all(A+B) = True -> all(A)=True and all(B)=True if all(A+B) = False -> all(A)=False or all(B)=False but we cannot assert either all(A)=False or all(B)=False. Now instead of B, lets add the empty set 0 to A. We want to come up logic such that adding the empty set does not change the values of all() or any(), since A+0=A. any(A+0) = any(A) or any(0) any(0) must be False, so that if any(A) is True, any(A+0) is True, and if any(A) is False, any(A+0) is False. all(A+0) = all(A) and all(0) if all(A) is True, all(A+0) is True. Therefore, all(0) is True. -- Paul -- http://mail.python.org/mailman/listinfo/python-list