Paul Watson wrote: > Eric Price 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 > > http://docs.python.org/tut/tut.html > http://docs.python.org/tut/node5.html#SECTION005140000000000000000 > http://docs.python.org/ref/slicings.html > > Probably most helpful to you is: > > http://developer.mozilla.org/es4/proposals/slice_syntax.html
Sorry. Probably most helpful to you is: http://docs.python.org/lib/built-in-funcs.html slice( [start,] stop[, step]) Return a slice object representing the set of indices specified by range(start, stop, step). The start and step arguments default to None. Slice objects have read-only data attributes start, stop and step which merely return the argument values (or their default). They have no other explicit functionality; however they are used by Numerical Python and other third party extensions. Slice objects are also generated when extended indexing syntax is used. For example: "a[start:stop:step]" or "a[start:stop, i]". -- http://mail.python.org/mailman/listinfo/python-list