enum_tools.custom_enums

Custom subclasses of enum.Enum and enum.Flag.

Classes:

AutoNumberEnum(value)

Enum that automatically assigns increasing values to members.

DuplicateFreeEnum(*args)

Enum that disallows duplicated member names.

IntEnum(value)

Enum where members are also (and must be) ints.

IterableFlag(value)

enum.Flag with support for iterating over members and member combinations.

IterableIntFlag(value)

enum.IntFlag with support for iterating over members and member combinations.

MemberDirEnum(value)

Enum which includes attributes as well as methods.

OrderedEnum(value)

Enum that adds ordering based on the values of its members.

StrEnum(value)

Enum where members are also (and must be) strings.

enum AutoNumberEnum(value)[source]

Bases: enum.Enum

Enum that automatically assigns increasing values to members.

enum DuplicateFreeEnum(value)[source]

Bases: enum.Enum

Enum that disallows duplicated member names.

enum IntEnum(value)[source]

Bases: int, enum.Enum

Enum where members are also (and must be) ints.

Member Type

int

flag IterableFlag(value)[source]

Bases: enum.Flag

enum.Flag with support for iterating over members and member combinations.

This functionality was added to Python 3.10’s enum module in #22221.

New in version 0.5.0.

flag IterableIntFlag(value)[source]

Bases: enum.IntFlag

enum.IntFlag with support for iterating over members and member combinations.

This functionality was added to Python 3.10’s enum module in #22221.

New in version 0.5.0.

Member Type

int

enum MemberDirEnum(value)[source]

Bases: enum.Enum

Enum which includes attributes as well as methods.

This will be part of the enum module starting with Python 3.10.

See also

Pull request #19219 by Angelin BOOZ, which added this to CPython.

New in version 0.6.0.

enum OrderedEnum(value)[source]

Bases: enum.Enum

Enum that adds ordering based on the values of its members.

The Enum and its members have the following methods:

__ge__(other)[source]

Return self>=value.

Return type

bool

__gt__(other)[source]

Return self>value.

Return type

bool

__le__(other)[source]

Return self<=value.

Return type

bool

__lt__(other)[source]

Return self<value.

Return type

bool

enum StrEnum(value)[source]

Bases: str, enum.Enum

Enum where members are also (and must be) strings.

Member Type

str