enums API documentation

# enums

View Source

     1import enum
     2
     3
     4class EnumDemo(enum.Enum):
     5    """
     6    This is an example of an Enum.
     7
     8    As usual, you can link to individual properties: `GREEN`.
     9    """
    10
    11    RED = 1
    12    """I am the red."""
    13    GREEN = 2
    14    """I am green."""
    15    BLUE = enum.auto()
    16
    17
    18class EnumWithoutDocstrings(enum.Enum):
    19    FOO = enum.auto()
    20    BAR = enum.auto()
    21
    22
    23class IntEnum(enum.IntEnum):
    24    FOO = enum.auto()
    25    BAR = enum.auto()
    26
    27
    28class StrEnum(enum.StrEnum):
    29    FOO = enum.auto()
    30    BAR = enum.auto()

class EnumDemo(enum.Enum): View Source

     5class EnumDemo(enum.Enum):
     6    """
     7    This is an example of an Enum.
     8
     9    As usual, you can link to individual properties: `GREEN`.
    10    """
    11
    12    RED = 1
    13    """I am the red."""
    14    GREEN = 2
    15    """I am green."""
    16    BLUE = enum.auto()

This is an example of an Enum.

As usual, you can link to individual properties: `GREEN`.

RED = <EnumDemo.RED: 1>

I am the red.

GREEN = <EnumDemo.GREEN: 2>

I am green.

BLUE = <EnumDemo.BLUE: 3>
class EnumWithoutDocstrings(enum.Enum): View Source

    19class EnumWithoutDocstrings(enum.Enum):
    20    FOO = enum.auto()
    21    BAR = enum.auto()

FOO = <EnumWithoutDocstrings.FOO: 1>
BAR = <EnumWithoutDocstrings.BAR: 2>
class IntEnum(enum.IntEnum): View Source

    24class IntEnum(enum.IntEnum):
    25    FOO = enum.auto()
    26    BAR = enum.auto()

FOO = <IntEnum.FOO: 1>
BAR = <IntEnum.BAR: 2>
class StrEnum(enum.StrEnum): View Source

    29class StrEnum(enum.StrEnum):
    30    FOO = enum.auto()
    31    BAR = enum.auto()

FOO = <StrEnum.FOO: 'foo'>
BAR = <StrEnum.BAR: 'bar'>