<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 1 July 2018 at 20:47, Ethan Furman <span dir="ltr"><<a href="mailto:ethan@stoneleaf.us" target="_blank">ethan@stoneleaf.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 07/01/2018 06:03 AM, Ivan Levkivskyi wrote:> On 27 June 2018 at 15:46, Ethan Furman wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
[...]<br>
So I'm asking the community:  What real-world examples can you offer for either behavior?  Cases where nested<br>
classes should be enum members, and cases where nested classes should not be members.<br>
</blockquote>
<br>
I wanted few times to make an enum of enums. For example:<br>
<br>
class  Method(Enum):<br>
     Powell = 1<br>
     Newton_CG = 2<br>
     <few more><br>
     class Trust(Enum):<br>
         Constr = 3<br>
         Exact = 4<br>
         <few more><br>
<br>
So that one can write:<br>
<br>
minimize(..., method=Method.Powell)<br>
minimize(..., method=Method.Trust.Exact)  # this currently fails<br>
</blockquote>
<br></span>
In such a case, would you want/expect for<br>
<br>
--> list(Method)<br>
<br>
to return<br>
<br>
[<Powel: 1>, <Newton_CG: 2>, ..., <Trust: -something->]<br>
<br>
?<br></blockquote><div><br></div><div>I am fine with what `list(Method)` does currently:</div><div><br></div>[<Method.Powell: 1>, <Method.Newton_CG: 2>, <Method.Trust: <enum 'Trust'>>]<div><br></div><div>I think it is intuitive that the nested enums are _not_ automatically flattened. Also it is easy to write a helper that<br></div><div>manually flattens nested enums, but it would be tedious to group them back if they are already flattened.</div><div><br></div><div>The only thing that I find a bit unintuitive is that one needs to write `Method.Trust.value.Exact` instead of just</div>`Method.Trust.Exact`.</div><div class="gmail_quote"><br><div>Maybe his can be allowed by adding a `__getattr__` to `Method` (by the metaclass) that will check if a value is an enum and</div><div>delegate the attribute access.</div><div><br></div><div>--</div><div>Ivan</div><div><br></div><div><br></div></div></div></div>