3

I have a generator, what is the most pythonic way to get its output placed in lists of N elements?

For instance, in the code:

>>> the_splitter(xrange(11).__iter__(), 3)
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10]]

i want the definition of the_splitter() function.

lvella
  • 12,754
  • 11
  • 54
  • 106
  • 2
    See also [this question](http://stackoverflow.com/questions/13239591/python-is-there-a-library-function-for-chunking-an-input-stream). – DSM Oct 02 '13 at 14:37
  • See [this answer](http://stackoverflow.com/questions/4356329/creating-a-python-dictionary-from-a-line-of-text/4356415#4356415) to related question. – martineau Oct 02 '13 at 14:51

0 Answers0