Popular recipes tagged "partition" but not "combinatorics"http://code.activestate.com/recipes/tags/partition-combinatorics/2013-01-21T16:20:17-08:00ActiveState Code RecipesSplit a sequence or generator using a predicate (Python) 2013-01-21T16:20:17-08:00Paul McGuirehttp://code.activestate.com/recipes/users/1377254/http://code.activestate.com/recipes/578416-split-a-sequence-or-generator-using-a-predicate/ <p style="color: grey"> Python recipe 578416 by <a href="/recipes/users/1377254/">Paul McGuire</a> (<a href="/recipes/tags/partition/">partition</a>, <a href="/recipes/tags/sequence/">sequence</a>, <a href="/recipes/tags/splitting/">splitting</a>). Revision 3. </p> <p>Split a sequence or generator into two iterators, each iterating over the elements that either pass or fail a predicate function.</p> string multi-partitioning (Python) 2010-03-26T20:03:59-07:00Michael Grünewaldhttp://code.activestate.com/recipes/users/4172244/http://code.activestate.com/recipes/577017-string-multi-partitioning/ <p style="color: grey"> Python recipe 577017 by <a href="/recipes/users/4172244/">Michael Grünewald</a> (<a href="/recipes/tags/partition/">partition</a>, <a href="/recipes/tags/string/">string</a>). Revision 6. </p> <p>Works like the <code>partition</code> method of strings in Python2.5+, but has support for more than one delimiter.</p> <p><em>Better description by Gabriel Genellina:</em></p> <blockquote> <p>Split the string at separator boundaries. The separators are searched from left to right, in the same order specified, and one after another. Unlike <code>partition</code>, all of them must be present (else <code>ValueError</code> is raised). Only one split per separator occurrence is done. Returns a list containing one more element than separators were given: first, text from beginning of the string up to (but not including) the first separator; the first separator itself; text between the first separator and the second one; the second separator; and so on. The last element contains all text following the last separator.</p> </blockquote> Partition an iterable into n lists (Python) 2009-05-30T16:35:27-07:00Ian Eloffhttp://code.activestate.com/recipes/users/2227021/http://code.activestate.com/recipes/576785-partition-an-iterable-into-n-lists/ <p style="color: grey"> Python recipe 576785 by <a href="/recipes/users/2227021/">Ian Eloff</a> (<a href="/recipes/tags/iterator/">iterator</a>, <a href="/recipes/tags/partition/">partition</a>). </p> <p>This could also be easily modified to return n iterators, but was outside of my needs. Handy for splitting up the workload for use with multiple threads/processes.</p>