PEP 289: universal and existential operators

Mark Hahn mark at hahnca.com
Thu Nov 6 05:43:24 CET 2003


Python doesn't use iftrue and whentrue, so why should it use alltrue and
anytrue?  I vote for all and any.

"Jeremy Fincher" <tweedgeezer at hotmail.com> wrote in message
news:698f09f8.0311051223.39271429 at posting.google.com...
> Alex Martelli <aleax at aleax.it> wrote in message
news:<g88qb.418190$R32.13848636 at news2.tin.it>...
> > I'm not sure what these calls are meant represent -- maybe an
> > interface similar to filter, i.e. a callable then a sequence?
> > The functions we're considering, whatever their names, would
> > in any case just take an iterator, so, e.g.:
> >
> > if all(x.isupper() for x in line.split()):
> >
> > and the like.
>
> Yeah, I suppose that is the case :)  I was stuck in FP mode (and
> without-generator-expressions mode; I use those two functions in my
> own code all the time)
>
> > I'll pass on that.  Maybe.  I think I still prefer alltrue and
anytrue...
>
> I'm afraid those names would inspire people to write code like this:
>
> alltrue(bool(x) for x in someIterable)
>
> I think the "true" in the function names might make people think it
> constrains the type to be a bool, which, if it resulted in code as
> above, would definitely be unfortunate.
>
> Jeremy






More information about the Python-list mailing list