git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Enum with nested classes or with types as members


Greetings!

So the stdlib Enum has been around for a few years now.  Has anyone 
written an enum that either had types as members:

   class Types(Enum):
       Int = int
       Str = str

or that had nested classes:

   class Types(Enum):
      class Contained(Enum):
          circle = 1
          square = 2
      class style:
          something = 'yay!'

?

If you have, why?  Were you able to do everything you wanted, or did you 
have to work around any issues?

I'm asking because in doing some work on Enum it became apparent to me 
that having nested classes was not a smooth, satisfying experience, and 
I'm considering treating them the same way as methods (they will no 
longer be converted into members).

So if you use that functionality, tell me now!  :)

--
~Ethan~