On this page
  1. enum.ReprEnum
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

enum.ReprEnum

Prev: enum.property | Up: enum | Next: enum.StrEnum
Rel: enum.auto, enum.Enum, enum.EnumCheck, enum.EnumDict
Ref: docs.python.org — enum.ReprEnum
Tags: #public #python3 #stdlib #enum


Import

import enum
from enum import ReprEnum

Signature & Overview

enum.ReprEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)

Only changes the repr(), leaving str() and format() to the mixed-in type.

Usage

from enum import ReprEnum

class FloatEnum(float, ReprEnum):
    HALF = 0.5
    ONE = 1.0

assert str(FloatEnum.HALF) == "0.5"
assert repr(FloatEnum.HALF) == "<FloatEnum.HALF: 0.5>"

Gotchas

REPL Inspect

from enum import ReprEnum
help(ReprEnum)

Linked from

Related notes