Any, All predicates (and vector operations for free)

Wed Feb 19 08:12:22 CET 2003

On Tue, 18 Feb 2003 14:45:55 -0700, rumours say that Steven Taschuk
<staschuk at> might have written:

> least in simple cases.  Even if these quantifiers could be
>composed directly, it's not immediately obvious what
>	Any(All(L)) > 2
>is supposed to mean.  Also, quantifying at the variable rather
>than around the whole statement (as is usual in logic) has
>disadvantages when the variable occurs more than once:
>	All(L).startswith('a') and All(L).endswith('z')
>will spin L twice, which precludes the use of this kind of
>expression with generic iterables.

Yes, this is a flaw of the module, thanks for the pointer.  A special
method that allows All(it, func) can always be added.

>Imho such issues outweigh the impressively sexy syntax, and
>motivate something like all(it, func).  (It would be natural to
>base such functions on map and filter, if those returned iterators
>when their arguments were iterators...  but separate, iterator-
>returning versions of map and filter might be best.)

This is what the itertools module is for (post-2.3a1 --thanks,
Raymond!).  I used its functions in the latest version of the predicates
module, which still hasn't shown up in the Vaults...
If you wait for the next alpha release (or if you compile the current
CVS tree) you will have imap and ifilter to use :)
TZOTZIOY, I speak England very best,
Real email address: 'dHpvdEBzaWwtdGVjLmdy\n'.decode('base64')

More information about the Python-list mailing list