<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 29, 2013 at 7:30 PM, Philip Jenvey <span dir="ltr"><<a href="mailto:pjenvey@underboss.org" target="_blank">pjenvey@underboss.org</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On Apr 29, 2013, at 3:25 PM, Eli Bendersky wrote:<br>
<br>
> On Mon, Apr 29, 2013 at 2:59 PM, Ethan Furman <<a href="mailto:ethan@stoneleaf.us">ethan@stoneleaf.us</a>> wrote:<br>
> In the Planet example we saw the possibility of specifying arguments to enum item __init__:<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       # in kilograms<br>
>         self.radius = radius   # in meters<br>
><br>
> Do we want to support this?<br>
><br>
> I'm -1, and this is yet another bad sign of conflating enums with classes. If planets want to have attributes and behaviors, let them be normal classes. If they want a PlanetId *enum member*, that's OK, but there's no need to intermix the two.<br>


<br>
</div>You may be right about the Planet example, but I wouldn't go that far. Additional metadata on Enum instances can be a handy feature in some cases, like documentation, e.g.:<br>
<br>
class Protocol(Enum):<br>
<br>
 HOPOPT = 0, "IPv6 Hop-by-Hop Option"<br>
 ICMP = 1, "Internet Control Message"<br>
 IGMP = 2, "Internet Group Management"<br>
<br>
 @property<br>
 def value(self):<br>
     return self._value[0]<br>
<br>
 @property<br>
 def description(self):<br>
   return self._value[1]<br></blockquote><div><br></div><div>Note that I don't object to adding certain behaviors to enums. I'm against taking it too far. One example of taking it too far is special implementation provisions to make enum be more like other classes, complicating the implementation just for this cause.<br>

<br>Eli<br></div></div></div></div>