#NEWLINE# def block_iter( l , nblocks = 2 ) : #NEWLINE# #INDENT# '\n    partitions l into nblocks blocks and returns generator over each block\n    @param l list\n    @param nblocks number of blocks to partition l into\n    ' #NEWLINE# blocksize = int ( math . ceil ( ( len ( l ) / float ( nblocks ) ) ) ) #NEWLINE# i = 0 #NEWLINE# while ( i < len ( l ) ) : #NEWLINE# #INDENT# ( yield l [ i : ( i + blocksize ) ] ) #NEWLINE# i += blocksize