[Python-ideas] itertools.documentation.ncycles is a bit of a sore thumb

Raymond Hettinger raymond.hettinger at gmail.com
Wed Aug 3 17:54:25 CEST 2011


On Aug 3, 2011, at 9:39 AM, Julian Berman wrote:

> def ncycles(iterable, n):
>  return chain.from_iterable(repeat(tuple(iterable), n))
> 
> Somewhere along the line something was going to need to buffer that, but it'd be nicer if the example didn't have the buffering done all at once at the outset as it is now.
> 
> Perhaps more importantly, though, is there a specific objection to just adding a count to itertools.cycle much like itertools.repeat has now for this?


The optional argument has never been requested and I don't see ncycles() being used enough in-practice to warrant adding complexity to the API.  The recipe for ncycles() is included in the docs as a way of teaching how itertools can be composed.   


Raymond


See:  http://www.google.com/codesearch#search/&q=ncycles%20lang:%5Epython


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110803/cd641b0d/attachment.html>


More information about the Python-ideas mailing list