title: Slicing a list into n nearly-equal-length partitions
body: <p>I'm looking for a fast, clean, pythonic way to divide a list into exactly n nearly-equal partitions.</p>
  
  <pre><code>partition([1,2,3,4,5],5)-&gt;[[1],[2],[3],[4],[5]]
  partition([1,2,3,4,5],2)-&gt;[[1,2],[3,4,5]] (or [[1,2,3],[4,5]])
  partition([1,2,3,4,5],3)-&gt;[[1,2],[3,4],[5]] (there are other ways to slice this one too)
  </code></pre>
  
  <p>There are several answers in here <a href="https://stackoverflow.com/questions/1335392/iteration-over-list-slices">Iteration over list slices</a> that run very close to what I want, except they are focused on the <em>size</em> of the list, and I care about the <em>number</em> of the lists (some of them also pad with None).  These are trivially converted, obviously, but I'm looking for a best practice.</p>
  
  <p>Similarly, people have pointed out great solutions here <a href="https://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python">How do you split a list into evenly sized chunks?</a> for a very similar problem, but I'm more interested in the number of partitions than the specific size, as long as it's within 1.  Again, this is trivially convertible, but I'm looking for a best practice.</p>