<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 29, 2013 at 2:45 PM, Terry Jan Reedy <span dir="ltr"><<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</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 4/29/2013 8:24 AM, Eli Bendersky wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks for the summary. One issue I don't see addressed here is<br>
int-compatibility. Am I correct to assume that nothing changes w.r.t.<br>
that, and that an IntEnum subclass of Enum will be provided which is<br>
isinstance(integer)? Does that become straightforward by nature of enum<br>
values being the type of their enumerations?<br>
</blockquote>
<br></div>
My only concern is that whatever you do does not break transitivity of ==. Aside from that, I will be happy with whatever you end up with and use it as appropriate.<br></blockquote></div><br></div><div class="gmail_extra">

The transitivity of == is not broken by either proposal. In PEP 435, the split to Enum and IntEnum is made in part for this reason. Enum values don't compare equal even if they have the same underlying values. IntEnum values do compare equal to ints, and hence to each other. So:<br>

<br></div><div class="gmail_extra">class Color(Enum):<br></div><div class="gmail_extra">  red = 1<br></div><div class="gmail_extra">  blue = 2<br><br></div><div class="gmail_extra">class Animal(Enum):<br></div><div class="gmail_extra">

  dog = 2<br></div><div class="gmail_extra">  sheep = 7<br><br></div><div class="gmail_extra">Color.blue != Animal.dog, and neither compares to 2, of course.<br>However, had both enums been IntEnum, we'd have:<br><br>

</div><div class="gmail_extra">Color.blue == Animal.dog == 2<br><br></div><div class="gmail_extra">This is a werdness users of IntEnum have to live with, and that's why it's explicitly discouraged for 99% of the use-cases.<br>

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