eof

Boris Borcic bborcic at gmail.com
Thu Nov 22 09:29:03 EST 2007


Duncan Booth wrote:

> Nice, thank you.

Welcome.

> But why 'count(chunksize)' rather than just 'count()'? 

To number the first chunk 1, etc. using count() starts with 0. Matter of taste.

> Does it make a difference anywhere? And I'd recommend using // rather than 
> / otherwise it breaks if you do 'from __future__ import division':

Right.

> 
> def chunked(chunksize,f) :
>      from itertools import count,groupby
>      counter=count().next
>      return groupby(f,lambda _ : counter()//chunksize)
> 




More information about the Python-list mailing list