Closed
Description
Bug report
Bug description:
Enums' exclusive access to _sunder_ members inhibits their use with the IPython/Jupyter pattern of making HTML and other visual reprs available:
from enum import Enum
class MyEnum(Enum):
A = 1
def _repr_html_(self):
return f'<span title="A MyEnum">{self}</abbr>'
# ValueError: _sunder_ names, such as '_repr_html_', are reserved for future Enum use
While having exclusive access to some space is valuable, and prefixing enum's range is not practical (as that prefix would need to be repeated by users constructing the class), carving out some space for widespread functions that are not expected to conflict with Enum's internal use should be possible. I suggest that at least _repr_html_
should be allowed, possibly the whole _repr_
prefix.
CPython versions tested on:
3.12
Operating systems tested on:
Linux