itertools comments [Was: Re: RELEASED: Python 2.3a2]

Chad Netzer cnetzer at
Thu Feb 20 22:01:59 CET 2003

On Thu, 2003-02-20 at 07:53, Alexander Schmolck wrote:
> Guido van Rossum <guido at> writes:

> > - new module itertools: efficient looping constructs 

> Wouldn't `xfilter`, `xmap` etc. be a better naming convention than
> `ifilter`, `imap` etc? I'd propose this change for 2 reasons:

FWIW, I agree with your reasoning here.  Since we are stuck with xrange,
the new names should be consistent.

> Finally, among the tools I've cooked up myself over time and that aren't
> already covered by what's in the new module, I find the following 2
> (especially the first) to be the most useful and worthy of addition:
> def xgroup(iter,n=2):
> def xwindow(iter, n=2, s=1):
> A last thing, I think a `cycle` generator would be an really useful idiom to
> have, as it provides a much more readable and less errorprone way to achieve
> many of the things one normally has to use an awkward modulus construct
> for.

I like xgroup and xcycle, but xwindow could be a confusing name (and is
arguably less often needed than xgroup).  Any alternative names for
xwindow?  Also, is there any (non-obfuscated) way to get xgroup()
functionality from zip()?  It doesn't seem so.

At least there is now an izip() in itertools (although, again, I would
prefer the 'x' naming, or the addition of irange() and the deprecation
of xrange())

Bay Area Python Interest Group -

Chad Netzer
(any opinion expressed is my own and not NASA's or my employer's)

More information about the Python-list mailing list