On Wed, May 1, 2013 at 2:04 PM, Eli Bendersky <eli...@gmail.com> wrote: > > > > On Wed, May 1, 2013 at 2:00 PM, Antoine Pitrou <solip...@pitrou.net> wrote: >> >> On Wed, 1 May 2013 13:57:11 -0700 >> Eli Bendersky <eli...@gmail.com> wrote: >> > >> > I still don't understand what you mean, sorry. Like, this: >> > >> > class MyEmptyEnum(Enum): >> > pass >> > >> > Why would you want to subclass MyEmptyEnum ? >> > >> > Or do you mean this: >> > >> > class IntEnum(int, Enum): >> > pass >> > >> > Now I can have: >> > >> > class SocketFamily(IntEnum): >> > ?? >> > >> > If it's the latter, then why allow subclassing explicitly just for this >> > reason? >> >> Because I may want to share methods accross all concrete subclasses of >> IntEnum (or WhateverEnum). > > > You mean this? > > class BehaviorMixin: > # bla bla > > class MyBehavingIntEnum(int, BehaviorMixin, Enum): > foo = 1 > bar = 2
It's a common pattern to do this with a base class rather than a mixin, though, and I think the rule "only allow subclassing empty enums" makes a lot of sense. -- --Guido van Rossum (python.org/~guido) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com