Skip to main content

Advanced Enumerations (compatible with Python's stdlib Enum), NamedTuples, and NamedConstants

Project description

Advanced Enumerations (compatible with Python’s stdlib Enum), NamedTuples, and NamedConstants

aenum includes a Python stdlib Enum-compatible data type, as well as a metaclass-based NamedTuple implementation and a NamedConstant class.

An Enum is a set of symbolic names (members) bound to unique, constant values. Within an enumeration, the members can be compared by identity, and the enumeration itself can be iterated over. Support exists for unique values, multiple values, auto-numbering, and suspension of aliasing (members with the same value are not identical), plus the ability to have values automatically bound to attributes.

A NamedTuple is a class-based, fixed-length tuple with a name for each possible position accessible using attribute-access notation as well as the standard index notation.

A NamedConstant is a class whose members cannot be rebound; it lacks all other Enum capabilities, however.

Enum classes:

  • Enum: Base class for creating enumerated constants.

  • IntEnum: Base class for creating enumerated constants that are also

    subclasses of int.

  • Flag: Base class for creating enumerated constants that can be combined

    using the bitwise operations without losing their Flag membership.

  • IntFlag: Base class for creating enumerated constants that can be combined

    using the bitwise operators without losing their IntFlag membership. IntFlag members are also subclasses of int.

  • AutoNumberEnum: Derived class that automatically assigns an int value to each

    member.

  • OrderedEnum: Derived class that adds <, <=, >=, and > methods to an Enum.

  • UniqueEnum: Derived class that ensures only one name is bound to any one

    value.

Utility functions include:

  • convert: helper to convert target global variables into an Enum

  • constant: helper class for creating constant members

  • enum: helper class for creating members with keywords

  • export: helper to insert Enum members into a namespace (usually globals())

  • extend_enum: add new members to enumerations after creation

  • module: inserts NamedConstant and Enum classes into sys.modules

    where it will appear to be a module whose top-level names cannot be rebound

  • skip: class that prevents attributes from being converted to a

    constant or enum member

  • unique: decorator that ensures no duplicate members

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aenum-2.1.1.tar.gz (98.4 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

aenum-2.1.1-py3-none-any.whl (39.5 kB view details)

Uploaded Python 3

aenum-2.1.1-py2-none-any.whl (33.4 kB view details)

Uploaded Python 2

File details

Details for the file aenum-2.1.1.tar.gz.

File metadata

  • Download URL: aenum-2.1.1.tar.gz
  • Upload date:
  • Size: 98.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aenum-2.1.1.tar.gz
Algorithm Hash digest
SHA256 7db335677a33f3687801fa182651e617ecbaf4e257721c8bb61aaf8ae19168cb
MD5 1e45dfc5d59767a0950be095a7b50c1f
BLAKE2b-256 adfc88a980d3cc52f0c826e1b377597d3d32a3ddf739069341707e92ffdda3db

See more details on using hashes here.

File details

Details for the file aenum-2.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aenum-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d139c7f21fe9b9282f937c7116629d9e5f380dd269a2ce44ccb9a33470be52cd
MD5 0c4ff3a367f2b6f78b3566e31eee89d0
BLAKE2b-256 06fe859fd58a0300e30fb9967083b82dffc0840488e9396271854af0b8b8d464

See more details on using hashes here.

File details

Details for the file aenum-2.1.1-py2-none-any.whl.

File metadata

File hashes

Hashes for aenum-2.1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 bc62712d0066966e6825d02dcba366b4daf5a1c32c04a8555fd6323e56a9dfb5
MD5 806d759398b281418bc385d00a4d7cd4
BLAKE2b-256 7b4686f6e2ac3d4fc8df59d7a7479f655a3c4be1c1cee26d6582deb736513cfe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page