On Nov 25, 5:34 pm, Mark Dickinson <[EMAIL PROTECTED]> wrote:
> If you have Python 2.6 available, itertools.combination might be

That should be itertools.combinations, of course.

The idea is that to give a partition of e.g., a 5-element list
into 3 nonempty pieces, all you have to do is say where to break
the list.  There are 4 possible places to break (between the
1st and 2nd elements, 2nd and 3rd, etc.), and you've got to
make two breaks.  Then combinations(range(1, 5), 2) generates
all possible pairs of breaking points.

Mark
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to