a few extensions for the itertools

Paul McGuire ptmcg at austin.rr._bogus_.com
Sun Nov 19 16:34:18 EST 2006


"Mathias Panzenboeck" <e0427417 at student.tuwien.ac.at> wrote in message 
news:4560bfb0$0$10578$3b214f66 at tunews.univie.ac.at...
>I wrote a few functions which IMHO are missing in python(s itertools).
>
> You can download them here:
> http://sourceforge.net/project/showfiles.php?group_id=165721&package_id=212104
>
> A short description to all the functions:
>
Just a couple of questions:

> iproduct(iterable, start=0) -> value
> Returns the product of the elements of a iterable
> times the value of parameter 'start'.  When the
> iterable is empty, returns start.
>
Wouldn't 1 be a better default value for start?

> forall(predicate, iterable, default=True) -> bool
> Returns True, when for all elements x in iterable
> predicate(x) is True. When the iterable is empty,
> returns default.
>
>
> forany(predicate, iterable, default=False) -> bool
> Returns True, when for any element x in iterable
> predicate(x) is True. When the iterable is empty,
> returns default.
>
How are these different from all and any in Python 2.5?

-- Paul





More information about the Python-list mailing list