[Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library (original) (raw)
Serhiy Storchaka storchaka at gmail.com
Fri Apr 26 23:11:11 CEST 2013
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
26.04.13 05:13, Nick Coghlan написав(ла):
With a merged design, it becomes really hard to give the instances custom behaviour, because the metaclass will somehow have to differentiate between namespace entries that are intended to be callables, and those which are intended to be instances of the enum. This is not an easy problem to solve.
What if use mixins? Shouldn't it work without magic?
class ColorMethods:
def wave(self, n=1): for _ in range(n): print('Waving', self)
class Color(ColorMethods, Enum):
red = 1 white = 2 blue = 3 orange = 4
- Previous message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Next message: [Python-Dev] PEP 435 -- Adding an Enum type to the Python standard library
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]