aenum

Project description

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

WARNING: Version 3.1 has breaking changes in custom Enum settings WARNING: WARNING: AutoNumber has been removed WARNING: AutoValue has been removed

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

  • enum_property: property to enable enum members to have same named attributes

    (e.g. name and value)

  • 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

Download files

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

Source Distribution

Built Distributions

Filter files by name, interpreter, ABI, and platform.

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

Copy a direct link to the current filters

File details

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

File metadata

  • Download URL: aenum-3.1.17.tar.gz
  • Upload date:
  • Size: 137.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for aenum-3.1.17.tar.gz
Algorithm Hash digest
SHA256 a969a4516b194895de72c875ece355f17c0d272146f7fda346ef74f93cf4d5ba
MD5 bd988607bd8bc8ee4d352b4cb33b913a
BLAKE2b-256 07e98b283567c1fef7c24d1f390b37daede8b61593d8cdaffb8e95d571699e83

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aenum-3.1.17-py3-none-any.whl
  • Upload date:
  • Size: 165.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for aenum-3.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 8b883a37a04e74cc838ac442bdd28c266eae5bbf13e1342c7ef123ed25230139
MD5 c87316b8eabccf321b300dcf05606cbc
BLAKE2b-256 488d1fe30c6fd8999b9d462547c4a1bb6690bda24af38f2913c4bec7decb81f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aenum-3.1.17-py2-none-any.whl
  • Upload date:
  • Size: 151.6 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for aenum-3.1.17-py2-none-any.whl
Algorithm Hash digest
SHA256 0dad0421b2fbe30e3fb623b2a0a23eff823407df53829d6a72595e7f76f3d872
MD5 ae3ca2f59b688838a4ce686fe72c6f49
BLAKE2b-256 cd73e9952b336aa437cb1e16863a453984c7ccdd386a5018b0a59570451fad8a

See more details on using hashes here.