Skip to main content

Python Power set generator

Checked with mypy Ruff Hatch project Documentation PyPi


Installation

pip install powerset-generator

Example

import powerset_generator

for e in powerset_generator.subsets(["one", "two", "three", "three"]):
    print(e)

produces

set()
{'one'}
{'three'}
{'two'}
{'one', 'three'}
{'one', 'two'}
{'three', 'two'}
{'one', 'three', 'two'}

Note that the empty set, set() is included in the output and that the function treats the duplicated input element "three" as if it appeared only once. This is correct behavior the mathematical notion of power set.

See the more complete (perhaps excessively so) documentation for more details.

Credit

The code for the subsets() function is derived heavily from Allen Downey's Stack Overflow answer.

Metadata

Release files for powerset-generator 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for powerset-generator 0.1.3
File Size Uploaded
powerset_generator-0.1.3.tar.gz 55.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for powerset-generator 0.1.3
File Interpreter ABI Platform
powerset_generator-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 59.2 kB

Release files / powerset_generator-0.1.3.tar.gz

Download URL powerset_generator-0.1.3.tar.gz
Size 55.1 kB
Tags Source
SHA-256 checksum
How to use checksums
60230a2218ecf8c25d59c0581ab8c17df7694f960f2949bd1c8a9854f0c13607
BLAKE2b-256 checksum
How to use checksums
72c1f491bb2888ecac1846efb2e5f6d3fd7716d9db13e2721a9292353f229b57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release files / powerset_generator-0.1.3-py3-none-any.whl

Download URL powerset_generator-0.1.3-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
737b37b941c64463ed216a0f640bd111866b3b85bbbe2caa37bdc14113e8ff51
BLAKE2b-256 checksum
How to use checksums
5b787351aec2c11c9479fc7026cb7bb033ec32f14a170785079a8b264da3af97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.27.0

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page