This post originated from an RSS feed registered with Python Buzz
by Guyon Morée.
Original Post: 1e Python splitting up a sequence 12
Feed Title: gumuz' devlog
Feed URL: http://gumuz.looze.net/wordpress/wp-rss2.php
Feed Description: 'till dev do us part
11d
Occasionally I want to chop up a sequence, so that a new sequence is created of the same items, but as pieces of x. That's why I have the following tiny utility function. It could be a one-liner :)
def splitseq(seq,size):
return [seq[i:i+size] for i in range(0, len(seq), ...
2c