[Python-ideas] Re: len(Enum) should raise TypeError

2023-04-04 Thread Richard Hajek
I believe that is the core question. In my use case it caused a bug because I accidentally typed "Enum" instead of "MyEnum" and the "len" worked, which is something I did not expect. However I do not know how prevalent this mistake is. ___ Python-ideas

[Python-ideas] Re: len(Enum) should raise TypeError

2023-04-04 Thread Richard Hajek
> Yes, that is correct. Any subclass of Enum will also be a type, and will have a length. That is the correct and expected behavior, as described on https://docs.python.org/3/library/enum.html > Yeah, and I'm of the opinion that it's not a problem for Enum to have zero possible values, but to ha

[Python-ideas] Re: len(Enum) should raise TypeError

2023-04-04 Thread James Addison via Python-ideas
Hi Richard, On Tue, 4 Apr 2023 at 12:49, Richard Hajek wrote: > > I encountered that Enum having a len hid a mistake on my part. If len(Enum) > raised, my mistake would be immediately apparent, however at the end of the > day, my mistake was easily found. Can any Python linting tools (such as

[Python-ideas] Auto dedent -c arguments.

2023-04-04 Thread Jonathan Crall
I have what I think is a fairly low impact quality of life improvement to suggest for the python CLI. When I'm not working in Python I tend to be working in bash. But often I want to break out and do something quick in Python. I find the `python -c ` CLI very useful for this. For one liners it's p

[Python-ideas] Re: len(Enum) should raise TypeError

2023-04-04 Thread Jonathan Fine
Hi Here's a similar example $ python3 > Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> from collections import Counter > >>> cnt = Counter # Oops! > >>> cnt.update('abcde') > >>> cnt > > This is wh

[Python-ideas] Re: len(Enum) should raise TypeError

2023-04-04 Thread Ethan Furman
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)