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

Ivan Levkivskyi levkivskyi at gmail.com
Sun Jul 1 09:03:33 EDT 2018

Replying to the list this time.

On 27 June 2018 at 15:46, Ethan Furman <ethan at stoneleaf.us> wrote:

> [...]
> 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.

I wanted few times to make an enum of enums. For example:

class  Method(Enum):
    Powell = 1
    Newton_CG = 2
    <few more>
    class Trust(Enum):
        Constr = 3
        Exact = 4
        <few more>

So that one can write:

minimize(..., method=Method.Powell)
minimize(..., method=Method.Trust.Exact)  # this currently fails

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180701/138d3335/attachment.html>

More information about the Python-ideas mailing list