PyDocs

Nav

Data Types

Enum.__repr__

enum

method of Enum (source)
  • Enum.__repr__(self)
Return repr(self).
1 Example
>>> from enum import auto, Enum
>>> class OtherStyle(Enum):
...     ALTERNATE = auto()
...     OTHER = auto()
...     SOMETHING_ELSE = auto()
...     def __repr__(self):
...         cls_name = self.__class__.__name__
...         return f'{cls_name}.{self.name}'
...
>>> OtherStyle.ALTERNATE, str(OtherStyle.ALTERNATE), f"{OtherStyle.ALTERNATE}"
(OtherStyle.ALTERNATE, 'OtherStyle.ALTERNATE', 'OtherStyle.ALTERNATE')
from the Python docs
See Also
No see-alsos for enum/Enum.__repr__
0 Notes
No notes for Enum.__repr__