<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 12, 2013 at 2:17 PM, R. David Murray <span dir="ltr"><<a href="mailto:rdmurray@bitdance.com" target="_blank">rdmurray@bitdance.com</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">On Fri, 12 Apr 2013 14:06:55 -0700, Eli Bendersky <<a href="mailto:eliben@gmail.com">eliben@gmail.com</a>> wrote:<br>


> I actually think that having values with different types within a single<br>
> Enum is conceptually wrong and should be disallowed at creation time. With<br>
> enums, you either care or don't care about their actual value. If you don't<br>
> care (the most common use case of an enum, IMHO), then no problem here. If<br>
> you do care, then it's probably for very specific reasons most of which are<br>
> solved by IntEnum. I can't imagine why someone would need differently typed<br>
> values in a single enum - this just seems like a completely inappropriate<br>
> use of an enum to me.<br>
<br>
</div>I'm sure someone will come up with one :)<br>
<br></blockquote><div><br></div><div>Which is precisely the reason to ban it :)<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
But seriously, even if you require all values to be of the same type,<br>
that doesn't solve the sorting problem:<br>
<br>
>>> class Foo(enum.Enum):<br>
...    aa = object()<br>
...    bb = object()<br>
...<br>
<div class="im">>>> Foo<br>
Traceback (most recent call last):<br>
  File "<stdin>", line 1, in <module><br>
  File "./enum.py", line 103, in __repr__<br>
    for k in sorted(cls._enums)))<br>
</div>TypeError: unorderable types: object() < object()<br>
<br>
Now, you could *further* require that the type of enum values be<br>
sortable....but that point you really have no excuse for not allowing<br>
enum values to be compared :)<br></blockquote></div><br></div><div class="gmail_extra">I'm actually not really in favor of enum values being comparable. I think this is more a C-ism and does not cleanly settle with my concept of what an enum is. For comparable enums and other C-derived properties, IntEnum is out there, so call it maybe ;-)<br>

<br>Eli<br><br></div><div class="gmail_extra"><br></div></div>