[Python-Dev] Enum: subclassing? (original) (raw)
Eli Bendersky eliben at gmail.com
Wed May 1 23:04:11 CEST 2013
- Previous message: [Python-Dev] Enum: subclassing?
- Next message: [Python-Dev] Enum: subclassing?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, May 1, 2013 at 2:00 PM, Antoine Pitrou <solipsis at pitrou.net> wrote:
On Wed, 1 May 2013 13:57:11 -0700 Eli Bendersky <eliben at 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
Eli -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20130501/174ac665/attachment.html>
- Previous message: [Python-Dev] Enum: subclassing?
- Next message: [Python-Dev] Enum: subclassing?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]