2 May
2013
2 May
'13
3:07 a.m.
On 02/05/13 13:47, Steven D'Aprano wrote:
The most obvious use-case for subclassing enums is to extend them:
class Directions(Enum): north = 1 east = 2 west = 3 south = 4
class Directions3D(Directions): up = 5 down = 6
It doesn't necessarily follow that subclassing is the right mechanism for extending enums, though. If anything, you really want to "superclass" them. Maybe class Directions3D(Enum, extends = Directions): up = 5 down = 6 Then we could have issubclass(Directions, Directions3D) rather than the reverse. -- Greg