<div dir="ltr">Sounds to me really strange that the nested class would become a member. Probably because everything becomes a member unless it's a function (maybe decorated)?<br></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jun 27, 2018 at 7:47 AM Ethan Furman <<a href="mailto:ethan@stoneleaf.us">ethan@stoneleaf.us</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Consider the following Enum definition:<br>
<br>
class Color(Enum):<br>
RED = 1<br>
GREEN = 2<br>
BLUE = 3<br>
@property<br>
def lower(self):<br>
return self.name.lower()<br>
def spam(self):<br>
return "I like %s eggs and spam!" % self.lower<br>
class SomeClass:<br>
pass<br>
<br>
Which of the above Color attributes are enums, and which aren't?<br>
<br>
<br>
.<br>
<br>
<br>
.<br>
<br>
<br>
.<br>
<br>
Answer:<br>
<br>
- RED, GREEN, and BLUE are members<br>
<br>
- lower and spam() are not<br>
<br>
- SomeClass /is/ a member (but not its instances)<br>
<br>
<br>
Question:<br>
<br>
Should `SomeClass` be an enum member? When would it be useful to have an embedded class in an Enum be an enum member?<br>
<br>
<br>
The only example I have seen so far of nested classes in an Enum is when folks want to make an Enum of Enums, and the <br>
nested Enum should not itself be an enum member. Since the counter-example already works I haven't seen any requests <br>
for it. ;)<br>
<br>
So I'm asking the community: What real-world examples can you offer for either behavior? Cases where nested classes <br>
should be enum members, and cases where nested classes should not be members.<br>
<br>
Thanks!<br>
<br>
--<br>
~Ethan~<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">--Guido van Rossum (<a href="http://python.org/~guido">python.org/~guido</a>)</div>