Take the first n items of an iterator

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Jan 4 15:49:42 CET 2009


On Sun, 04 Jan 2009 11:10:05 +0000, Marc 'BlackJack' Rintsch wrote:

> On Sun, 04 Jan 2009 10:55:17 +0000, 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()`


Thanks Marc, time to check my glasses I think, I must have looked at that 
a dozen times and didn't draw the connection.


-- 
Steven



More information about the Python-list mailing list