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

Guido van Rossum guido at python.org
Sat Apr 27 19:30:50 CEST 2013

On Sat, Apr 27, 2013 at 9:41 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Sun, Apr 28, 2013 at 2:11 AM, Larry Hastings <larry at hastings.org> wrote:
>> On 04/26/2013 02:41 PM, Guido van Rossum wrote:
>> I am still optimistic that we can come up with a rule that
>> works well enough in practice (and the Zen rule to which I was
>> referring was, of course, "practicality beats purity").
>> The rule I liked best is "ignore callables, descriptors, and anything with
>> leading & trailing double underscores".  Personally I'd modify that to
>> simply "anything with two leading underscores" so you can have private
>> variables.  It seems Pythonic to me in that classes already treat all those
>> things special.  And if you want enums of any of those things you can
>> instantiate & insert them by hand after the class definition.
>> Does that fail in an important way?
> Nope, those cover it.

Great, sounds like a plan.  The  exception for callables may not even
be needed -- the callables we care about (and some non-callables, like
properties) are all descriptors. Or do we care about nested class
definitions?  (The reason I'm not keen on a general exemption for
callables is that some 3rd party objects you wouldn't necessarily
expect to be callable actually are.)

I agree on a general exemption for __dunder__ names. The problem with
exempting __private is that by the time the metaclass sees them,
they've already been mangled to _classname__private. And I could just
about imagine a use case for having a private value in an enum.

--Guido van Rossum (python.org/~guido)

More information about the Python-Dev mailing list