[Python-ideas] Should nested classes in an Enum be Enum members?
storchaka at gmail.com
Wed Jun 27 23:57:45 EDT 2018
27.06.18 17:46, Ethan Furman пише:
> Should `SomeClass` be an enum member? When would it be useful to
> have an embedded class in an Enum be an enum member?
> 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 nested Enum should not
> itself be an enum member. Since the counter-example already works I
> haven't seen any requests for it. ;)
> So I'm asking the community: What real-world examples can you offer for
> either behavior? Cases where nested classes should be enum members, and
> cases where nested classes should not be members.
What would be a benefit of making a class nested if it not be an enum
member? Nested functions become methods, but there are no relations
between a nested class or its instances and the outer class or its
The current behavior looks understandable to me. Functions are
descriptors, but classes are not. Making a nested class a member you
don't lost anything, because you always can make it not-nested if you
don't want it be a member. But when a nested class is not a member, you
would lost the possibility of making it a member (and this may break
More information about the Python-ideas