Sequence slicing [starting-at-index : but-less-than-index [ : step]]. Start defaults to 0, end to len(sequence), step to 1. So l[i::rows] means: slicing start from i, ending with len(l) and step with rows. So function colsplit(l, cols) returns a list of sequence with conversion of:
Assume cols = 4: From: ABCD ABCD ABCD AB To: AAAABBBBCCCDDD On Jan 4, 11:42 am, "Eric Price" <[EMAIL PROTECTED]> wrote: > Hello; > I'm studying some code examples from the python cookbook site. I came across > this: > > def colsplit(l, cols): > rows = len(l) / cols > if len(l) % cols: > rows += 1 > m = [] > for i in range(rows): > m.append(l[i::rows]) > return m > > What I'd like to know is what is the double colon? What does it do? > m.append(l[i::rows]) > > Thanks, > Eric > > _________________________________________________________________ > Type your favorite song. Get a customized station. Try MSN Radio powered > by Pandora.http://radio.msn.com/?icid=T002MSN03A07001 -- http://mail.python.org/mailman/listinfo/python-list