[Python-ideas] Should nested classes in an Enum be Enum members?

Random832 random832 at fastmail.com
Thu Jun 28 13:43:56 EDT 2018


On Wed, Jun 27, 2018, at 15:04, Elazar wrote:
> People working with sum types might expect the instances of the nested
> class to be instances of the enclosing class. So if the nested class is a
> namedtuple, you get a sum type. The only problem is that there's no way to
> express this subtype relationship in code.

I bet you could get around it with a custom __build_class__.

(As for preventing the nested class from being an enum member, @staticmethod works to get around that)


More information about the Python-ideas mailing list