any(), all() and empty iterable

Tim Chase python.list at
Thu Apr 16 20:27:25 CEST 2009

Raymond Hettinger wrote:
> I will not change the sentence to "return false if any element
> of the iterable is false."  The negations make the sentence
> hard to parse mentally 

Just as a ribbing, that "return X if any element of the iterable 
is X" is of the same form as the original.  The negation is only 
of the X, not of the sentence structure.

> I will probably leave the lead-in sentence as-is but may
> add another sentence specifically covering the case for
> an empty iterable.

as one of the instigators in this thread, I'm +1 on this solution.

Changing the implementation of all() would break waaaay too much 
stuff, so I'm -1 on that.  Adding a one-sentence clarification to 
the docs is a heckuva lot easier.

> P.S.  Now maybe we can start a new thread about why sum([])
> returns zero ;-)

NOOOOooooooo!  (runs screaming) :-)


More information about the Python-list mailing list