[New-bugs-announce] [issue21414] Add an intersperse function to itertools

Alexander Boyd report at bugs.python.org
Fri May 2 09:39:41 CEST 2014

New submission from Alexander Boyd:

Itertools would benefit greatly from a function (which I've named intersperse, after Haskell's equivalent) for yielding the items of an iterator with a given value placed between each. Sort of a str.join-like function, but for arbitrary sequences.

Something like:

>>> list(itertools.intersperse(1, [2, 3, 4]))
[2, 1, 3, 1, 4]

messages: 217746
nosy: javawizard
priority: normal
severity: normal
status: open
title: Add an intersperse function to itertools
type: enhancement

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list