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

Piotr Duda duda.piotr at gmail.com
Fri Apr 26 07:59:03 CEST 2013


2013/4/26 Nick Coghlan <ncoghlan at gmail.com>
>
> On Fri, Apr 26, 2013 at 8:29 AM, Barry Warsaw <barry at python.org> wrote:
> > On Apr 25, 2013, at 03:19 PM, Guido van Rossum wrote:
> >
> >>Clearly this is a trick question. :-)
> >
> > A bit, yes. :)
> >
> >>I was told when this was brought up previously (a week ago?) that it
> >>would be simple to make it truly the same class.
> >
> > It didn't sound simple to me, but I haven't seen any actual code yet.
>
> I'm the one who said I didn't see any obvious barriers to the merger,
> but I've realised there is one, and it's similar to one namedtuple
> struggles with: how to handle method definitions.

There is at least one more problem, enum inheritance, given:

class Colors(Enum):
  red = 1
  green = 2
  blue = 3

class MoreColors(Color):
  cyan = 4
  magenta = 5
  yellow = 6

what type is MoreColors.red?

--
闇に隠れた黒い力
弱い心を操る


More information about the Python-Dev mailing list