<div dir="ltr">On 6 May 2013 08:55, Eli Bendersky <span dir="ltr"><<a href="mailto:eliben@gmail.com" target="_blank">eliben@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div><div class="h5">1. That the dictionary returned from <enum metaclass>.__prepare__ provide a way to obtain the enum instance names once it's been populated (e.g. once it's been passed as the classdict to __new__). The reference implementation provides a _enum_names list attribute. The enum names need to be available to a metaclass subclass before calling the base metaclass __new__.<br>
<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">


<div><span style="color:rgb(34,34,34)">So your preferred solution is (1), which requires exposing the metaclass and an attribute publicly? I have to ask - to what end? What is the goal of this? To have an AutoNumberedEnum which is guaranteed to be compatible with stdlib's Enum? </span></div>
</div></div></div></blockquote></div></div></div></div></div></blockquote><div><br></div><div style>My preferred solution is 1 (for the reason mentioned above) but it does not require exposing the metaclass publically (that's obtainable via type(Enum)). It does require a way to get the enum names before calling the base metaclass __new__, but that does not necessarily imply that I'm advocating exposing _enum_names (or at least, not directly).</div>
<div style><br></div><div style>My preferred way would probably be a note that the dictionary returned from the enum metaclass __prepare__ implements an enum_names() or maybe __enum_names__() method which returns an iterator over the enum instance names in definition order. The way this is implemented by the dictionary would be an implementation detail.</div>
<div style><br></div><div style>The enum metaclass __new__ needs access to the enum instance names in definition order, so I think making it easily available to enum metaclass subclasses as well just makes sense.</div><div>
<br></div><div style>Tim Delaney</div></div></div></div>