[Python-ideas] Add 'interleave' function to itertools?

Guido van Rossum guido at python.org
Thu Aug 8 19:47:36 CEST 2013


On Thu, Aug 8, 2013 at 10:42 AM, David Mertz <mertz at gnosis.cx> wrote:
> I agree that most of the recipes for clever combinations of itertools
> functions--at least those that have intuitive and obvious names--should
> simply be put into the module itself (and per Andrew, they can nonetheless
> by documented as recipes).
>
> Even if these implementations can be done as one-liners that stitch together
> a few existing functions, that's not really any reason not to include them
> in the namespace.  There are too many ways to do those one-liners slightly
> wrong, and no need to add to the cognitive burden of someone who just wants
> to, e.g. interleave.

I'm not sure if I completely buy this line of argument. Coming up with
good names for all of them will become an issue, and people who can
easily reconstruct the recipes from first principles won't necessarily
be using them -- they may even have to look up the recipe by name
before they understand what is going on.

(Then again, feel free to ignore me. I rarely use the itertools module anyway.)

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list