
April 4, 2023
6:54 p.m.
On 4/1/23 07:45, Richard Hajek wrote:
# Feature or enhancement
`len(Enum)` has no useful meaning and should therefore raise the appropriate error
# Pitch
I cannot figure out any scenario, in which len(Enum) should not raise. Enum is a type and as any other types, such as `len(list)` or `len(dict)`, and should not give any meaningful result on len.
Enums are not like any other type in a multitude of ways: `__len__`, `__contains__`, `__getitem__`, etc. Special-casing only `Enum`, `IntEnum`, `StrEnum`, and every other base enum (i.e. no members), would be like special-casing empty lists, empty dicts, empty tuples, etc. -- ~Ethan~