Take the first n items of an iterator

2009-01-06 Thread Steven D'Aprano
I thought there was an iterator in itertools for taking the first n items of an iterator, then halting, but I can't find it. Did I imagine such a tool, or am I missing something? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: Take the first n items of an iterator

2009-01-04 Thread Marc 'BlackJack' Rintsch
On Sun, 04 Jan 2009 10:55:17 +, Steven D'Aprano wrote: I thought there was an iterator in itertools for taking the first n items of an iterator, then halting, but I can't find it. Did I imagine such a tool, or am I missing something? `itertools.islice()` Ciao, Marc 'BlackJack'

Re: Take the first n items of an iterator

2009-01-04 Thread Steven D'Aprano
On Sun, 04 Jan 2009 11:10:05 +, Marc 'BlackJack' Rintsch wrote: On Sun, 04 Jan 2009 10:55:17 +, Steven D'Aprano wrote: I thought there was an iterator in itertools for taking the first n items of an iterator, then halting, but I can't find it. Did I imagine such a tool, or am I