[Python-Dev] Adding any() and all()
Greg Ewing
greg.ewing at canterbury.ac.nz
Sun Mar 13 07:45:42 CET 2005
Nick Coghlan wrote:
> A suggestion was made on c.l.p a while back to have a specific module
> dedicated to reductive operations. That is, just as itertools is
> oriented towards manipulating iterables and creating iterators, this
> module would be oriented towards consuming iterators in a reductive fashion.
Is there really any need for another module just for this?
The distinction between reductive and non-reductive operations
on iterators seems rather too fine to me to deserve a whole
new module.
Why not just put them all in itertools?
> [1] While any()/all() read well in the context of an if statement, I
> think anytrue()/alltrue() better convey the reductive nature of the
> operations, read nearly as well in the if context, and read
> significantly better when isolated from the if context (e.g. assigned to
> a variable).
I don't agree. I think 'any' and 'all' are fine names for
boolean-valued functions in any context. Including 'true'
in their names smacks of the same kind of redundancy as
if blarg == True:
...
which is widely regarded as a naive-newbie style blunder
in any language.
+1 on 'any' and 'all'
-1 on any names including 'true' or 'false'
Greg
More information about the Python-Dev
mailing list