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~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/YW6PLGLW4N6ZAZWR6ELED2ZIIPL3E4XQ/
Code of Conduct: http://python.org/psf/codeofconduct/