[Python-ideas] Break the dominance of boolean values in boolean context

Alexander Belopolsky alexander.belopolsky at gmail.com
Wed Sep 14 18:17:13 CEST 2011

On Tue, Sep 13, 2011 at 8:59 PM, Ned Batchelder <ned at nedbatchelder.com> wrote:
> .. Why shouldn't any() also return Sx?

What is the use case for returning the first "trueish" value?  In most
cases, any() is used in boolean context, say

  if any(S):

In this case, returning Sx would result in Sx.__bool__() being called
twice.  It is also rare that any() is called on the raw sequence of
objects that are of interest.  More often it is used to express
predicates such as any(x < 0 for x in S).

More information about the Python-ideas mailing list