Skip to main content

enumset

collection of Enum classes.

Install

  • pip install enumset

Enumset

Enumset stores multiple Enum-class value, each value in Enum-class should be unique.

from enum import Enum, Flag
from enumset import Enumset

A = Enum("A", "A1 A2 A3")
B = Enum("B", "B1 B2")
C = Flag("C", "C1 C2 C3 C4")

es = Enumset([A, B, C])
es.setval(A.A1)
es.setval(B.B2)
es.setval(C.C3)
assert list(es.values()) == [A.A1, B.B2, C.C3]
assert es.getval(A) == A.A1

es.setval(A.A2)   # replace A1 -> A2
es.setval(C.C4)   # replace C3 -> C4
assert list(es.values()) == [A.A2, B.B2, C.C4]
assert es.getval(A) == A.A2

Flagset

Flagset stores multiple Enum-class value, like set[Enum].

from enum import Enum, Flag
from enumset import Flagset

A = Enum("A", "A1 A2 A3")
B = Enum("B", "B1 B2")
C = Flag("C", "C1 C2 C3 C4")

fs = Flagset([A, B, C])
fs.setval(A.A1)
fs.setval(B.B2)
fs.setval(C.C3)
assert list(fs.values()) == [A.A1, B.B2, C.C3]
assert list(fs.getval(A)) == [A.A1]

fs.setval(A.A2)   # A1+A2
fs.setval(C.C4)   # C3+C4
assert list(fs.values()) == [A.A1, A.A2, B.B2, C.C3, C.C4]
assert list(fs.getval(A)) == [A.A1, A.A2]
assert list(fs.getval(C)) == [C.C3, C.C4]

fs.setval(A.A2)   # A2 already exists
assert list(fs.values()) == [A.A1, A.A2, B.B2, C.C3, C.C4]

Metadata

Release files for enumset 0.2.0

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

Built distribution (wheel)

Table of built distributions (wheels) for enumset 0.2.0
File Interpreter ABI Platform Actions
enumset-0.2.0-py3-none-any.whl Python 3 none any Details for enumset-0.2.0-py3-none-any.whl

Release files / enumset-0.2.0-py3-none-any.whl

Download URL enumset-0.2.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42c9a59785c397dc54f9b9c45241899a1a3266b1a9d6a83127f1ce0b06479d71
BLAKE2b-256 checksum
How to use checksums
c5f1787c69207455b5e2e5b15ed82a1e2e42ef661dba3bd78c4843fe193d83b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for enumset 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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