title: Is there a way to instantiating a class directly from an Enum?
body: <p>I recently found out you can use enums in Python, but I'm not happy with how my code is working and I'm wondering if there is a cleaner way to implement it.</p>
  
  <pre class="lang-py prettyprint-override"><code>from enum import Enum
  
  class Hex:
      def __init__(self, hex_code: str):
          self.code = hex_code
  
  class Rgb:
      def __init__(self, R: int, G: int, B: int):
          self.r = R
          self.g = G
          self.b = B
  
  class Color(Enum):
      HEX = Hex
      RGB = Rgb
  
  def main():
      hex_color = Color.HEX.value('#00FF00')
      rgb_color = Color.RGB.value(255, 255, 255)
  
  if __name__ == "__main__":
      main()
  </code></pre>
  
  <p>In this example I have to instantiate by calling the <code>.value()</code> enum method. but when you instantiate a class normally, all you do is <code>Class(value)</code>. Would it be possible to implement something similar to enum variants that holds a class?
  For example:</p>
  
  <pre class="lang-py prettyprint-override"><code>Color.HEX('#00FF00')
  # Instead of:
  Color.HEX.value('#00FF00')
  </code></pre>