On Saturday, April 27, 2013, Greg Ewing  wrote:<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This whole business can be avoided by doing things differently<br>
in the first place. Instead of initialising the enum items by<br>
calling the class, just assign a tuple of args to the name<br>
and have the metaclass make the constructor call.<br>
<br>
  class Planet(Enum):<br>
    MERCURY = (3.303e+23, 2.4397e6)<br>
    VENUS   = (4.869e+24, 6.0518e6)<br>
    EARTH   = (5.976e+24, 6.37814e6)<br>
    MARS    = (6.421e+23, 3.3972e6)<br>
    JUPITER = (1.9e+27,   7.1492e7)<br>
    SATURN  = (5.688e+26, 6.0268e7)<br>
    URANUS  = (8.686e+25, 2.5559e7)<br>
    NEPTUNE = (1.024e+26, 2.4746e7)<br>
<br>
    def __init__(self, mass, radius):<br>
      self.mass = mass<br>
      self.radius = radius<br>
<br>
I think that's better anyway, since it avoids aggravated<br>
violation of DRY by repeating the class name umpteen times.<br>
</blockquote><div><br></div><div>If you want something like this, doyou really have to inherit from Enum?<span></span> </div><br><br>-- <br>--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)<br>