title: Segment a list in Python
body: <p>I am looking for an python inbuilt function (or mechanism) to segment a list into required segment lengths (without mutating the input list). Here is the code I already have:</p>
  
  <pre><code>&gt;&gt;&gt; def split_list(list, seg_length):
  ...     inlist = list[:]
  ...     outlist = []
  ...     
  ...     while inlist:
  ...         outlist.append(inlist[0:seg_length])
  ...         inlist[0:seg_length] = []
  ...     
  ...     return outlist
  ... 
  &gt;&gt;&gt; alist = range(10)
  &gt;&gt;&gt; split_list(alist, 3)
  [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
  </code></pre>