This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Partition Sets provides a consolidated set of recipes gently provided by other users over the years and under the MIT license. I modified these slightly so that they now equally work under python2 and python3. All bugs are mine ;-)

You may find it useful for tasks involving small sets and also multi sets/bags.


A simple pip install PartitionSets should suffice.


Typical usage in python code might look like this:

#!/usr/bin/env python

from __future__ import print_function
from partitionsets import ordered_set
from partitionsets import partition

a_list = 'red green yellow blue'.split(" ")
an_oset = ordered_set.OrderedSet(a_list)
a_partition = partition.Partition(ordered_set)
for a_part in a_partition:
    print (a_part)

The sript inside the bin folder may offer useful commands. For usage info run it with the -h help option:

$> -h
usage: [-h] [-q | -v] [-o OUT_FILENAME] [-T {text,csv,json}]
                         [-b] [-m]
                         element [element ...]

partitioning of small sets with 25 or less members

positional arguments:
  element               define set as list of elements separated by spaces

optional arguments:
  -h, --help            show this help message and exit
  -q, --quiet
  -v, --verbosity       increase output verbosity
  -o OUT_FILENAME, --out-filename OUT_FILENAME
                        out file name if specified, else all sent to stdout
  -T {text,csv,json}, --type {text,csv,json}
                        type of output (format), defaults to text
  -b, --bell-numbers    export the Bell numbers known by package
  -m, --multi-set       handle elements as being par tof a multiset or bag


Note this implementation works only for sets with 25 members or less.

This constraint is considered quite reasonable, as the method (constructing an integer index) for larger numbers starts to overflow. Remember: The number of partitions very steeply rises with each additional member considerably …

Thanks also to

This package merely wraps up several recipes (and comments) gently provided under the MIT license through several people. Those I noticed have been noted below. Any missing names are my fault. In case I get notified, I will try to update, add or remove items in below lists accordingly.


  • Anton Vredegoor
  • Chris Haulk


  • Don Sawatzky
  • Emil Wall
  • Raymond Hettinger


For further reference please see the comments of the module files.


[A0001101]: “Bell or exponential numbers: ways of placing n labeled balls
into n indistinguishable boxes.” at
[BellNumber]: Wikipedia entry Bell_number
[OEIS]: Wikipedia entry On-Line_Encyclopedia_of_Integer_Sequences at


[OrdSetImplPy]: (mixed with
the simplified code from Don Sawatzky’s comment, which is sufficient for this task)

[PartImplPy]: (r1)

[PartOfASet_WP]: Wikipedia entry Partition_of_a_set at


Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
PartitionSets-0.1.1.tar.bz2 (8.9 kB) Copy SHA256 Checksum SHA256 Source Mar 4, 2013
PartitionSets-0.1.1.tar.gz (8.8 kB) Copy SHA256 Checksum SHA256 Source Mar 4, 2013 (15.3 kB) Copy SHA256 Checksum SHA256 Source Mar 4, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting