It has been explained before but i will find a link.
–
jamylakApr 28 '12 at 14:30

2

That is exceedingly clever, but I guess it is pythonic.
–
ddaaApr 28 '12 at 14:54

7

Note that this discards incomplete chunks. If you try it with x = [1,2,3,4,5,6,7] then you only get two chunks, and the 7 is discarded. (Of course, this might be what you want, but if it isn't, beware!)
–
gimbolandJun 14 '13 at 0:00

@gimboland that input is invalid because there are no possible even chunks from that
–
jamylakJun 14 '13 at 1:23

This just seems like a less readable version of my code...
–
jamylakApr 28 '12 at 15:23

This exact code is provided in the accepted answer in the link in jamylak's post.
–
AkavallApr 28 '12 at 15:28

I guess it's okay to know that it works but I wouldn't recommend using it because of what I said before.
–
jamylakApr 28 '12 at 15:32

4

@jamylak, actually, this does someting slightly different from what your code does. Look at the result of map(None, *[iter(range(10))]*3)) vs zip(*[iter(range(10))]*3). Since the OP didn't specify which behavior he or she wants, this answer is valid.
–
senderleApr 28 '12 at 15:35

1

@senderle for that i would use izip_longest. That is also used in the example for itertools
–
jamylakApr 28 '12 at 15:36