itertools comments [Was: Re: RELEASED: Python 2.3a2]
Christian Tanzer
tanzer at swing.co.at
Fri Feb 21 11:45:00 EST 2003
"Raymond Hettinger" <python at rcn.com> wrote:
> > def xgroup(iter,n=2):
> > r"""Iterate `n`-wise (default pairwise) over `iter`.
>
> Sounds interesting enough to put on the list of ideas being
> entertained. Also, it is consistent with the idea of "iterator
> algebra".
>
> For the time being, my goal is to start with a small set of
> tools that have proven useful in Haskell and SML. Over
> time, other candidates will considered.
>
> This one would have a much better chance if some common
> use cases could be shown and if it can be demonstrated that
> it is a useful building block in combination with the other
> itertools.
I happen to use this function. Greping over my source tree for
`pairwise` shows 46 uses in 1074 files (disclaimer: that is
a usage frequency of only 0.00017 <wink>).
Typical usage (blatantly made up):
def test_sort(some_list) :
sorted_list = myq_sort(some_list)
for l, r in pairwise(sorted_list) :
assert l <= r
I never needed anything like `triplewise`, though.
--
Christian Tanzer tanzer at swing.co.at
Glasauergasse 32 Tel: +43 1 876 62 36
A-1130 Vienna, Austria Fax: +43 1 877 66 92
More information about the Python-list
mailing list