[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library

Nick Coghlan ncoghlan at gmail.com
Fri Apr 26 07:30:06 CEST 2013

On Fri, Apr 26, 2013 at 3:01 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> On 26/04/13 13:22, Greg wrote:
>> On 26/04/2013 3:12 p.m., Glenn Linderman wrote:
>>> On 4/25/2013 7:49 PM, Nick Coghlan wrote:
>>>> You couldn't create an enum of callables, but that would be a
>>>> seriously weird thing to do anyway....
>>> But aren't all classes callable?
>> An enum of classes would be seriously weird as well, I think.
> I don't think iscallable will work, since that descriptors like
> staticmethod and classmethod aren't callable. Nor are properties.

My point was there *are* broad categories that we can reasonably say
"you can't use these as values in an enumeration". Callables are one,
descriptors are probably another.

Alternatively, we can flip it around and require that each enum
definition nominate an expected value type (defaulting to int) and
only convert class attributes that are instances of that type to
instances of the enum class.

Either can be made to work, so it's really Guido's call as to which he
would prefer. As Barry noted, the next step is actually for someone to
create a proof of concept that shows the merge is possible in
practice, not just theory.


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list