Skip to content

Partition Sets

Consolidation of existing third party recipes for partitioning of sets and multisets/bags.

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.

License: MIT

version downloads wheel supported-versions supported-implementations

Bug Tracker

Feature requests and bug reports are best entered in the todos of partitionsets.

Primary Source repository

The primary source of partitionsets lives somewhere on a mountain in Central Switzerland. But, we use decentralized version control (git), so any clone can become the source to everyone's benefit, no central only code. Anyway, the preferred public clones of partitionsets are:

  • on codeberg - a democratic community-driven, non-profit software development platform operated by Codeberg e.V.
  • at sourcehut - a collection of tools useful for software development.

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


  • Nathan Hurst send feedback and a patch for version 0.1.1 - thanks

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 at

[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)

[PartOfASet_WP]: Wikipedia entry Partition_of_a_set at