This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author David Hagen
Recipients David Hagen, John Hagen, abarry, barry, eli.bendersky, ethan.furman, kennethreitz, python-dev, rhettinger, veky, vstinner
Date 2016-08-19.17:11:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1471626696.28.0.447855244538.issue26988@psf.upfronthosting.co.za>
In-reply-to
Content
One solution similar to one proposed by Vedran works with the current Enum:

    class Color(Enum):
        red = object()
        green = object()
        blue= object()

I tested this in PyCharm and it is perfectly happy with the autocomplete and everything. The main disadvantage is the boilerplate, of course. And perhaps "object()" does not show the clearest intent, but it depends on your perspective. The repr also looks kind of funny:

    >>>  repr(Color.red)
    <Color.red: <object object at 0x7fb2f353a0d0>>

One possibility would be to add an auto() function to enum as a wrapper around object(), providing a more explicit name and a cleaner repr:

    from enum import Enum, auto

    class Color(Enum):
        red = auto()
        blue = auto()
        green = auto()

    repr(Color.red)
    <Color.red>
    # auto() means it has no (meaningful) value, so show nothing
History
Date User Action Args
2016-08-19 17:11:36David Hagensetrecipients: + David Hagen, barry, rhettinger, vstinner, eli.bendersky, ethan.furman, python-dev, veky, abarry, John Hagen, kennethreitz
2016-08-19 17:11:36David Hagensetmessageid: <1471626696.28.0.447855244538.issue26988@psf.upfronthosting.co.za>
2016-08-19 17:11:36David Hagenlinkissue26988 messages
2016-08-19 17:11:35David Hagencreate