On Wed, 1 May 2013 14:04:11 -0700
Eli Bendersky <[email protected]> wrote:
>
> You mean this?
>
> class BehaviorMixin:
> # bla bla
>
> class MyBehavingIntEnum(int, BehaviorMixin, Enum):
> foo = 1
> bar = 2
Yes, but without the need for multiple inheritance and separate
mixins ;-) Especially if the behaviour is enum-specific, e.g.:
class IETFStatusCode(IntEnum):
@classmethod
def from_statusline(cls, line):
return cls(int(line.split()[0]))
class HTTPStatusCode(IETFStatusCode):
NOT_FOUND = 404
class SIPStatusCode(IETFStatusCode):
RINGING = 180
Regards
Antoine.
_______________________________________________
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com