any(), all() and empty iterable

Dale Roberts gooberts at gmail.com
Thu Apr 16 14:46:24 EDT 2009


On Apr 16, 2:27 pm, Tim Chase <python.l... at tim.thechases.com> wrote:
> 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.

Yes, I now appreciate the motivation for having the word "all" in the
text, and simply adding something like "or the iterable is empty"
might head off future confusion.

dale



More information about the Python-list mailing list