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 ethan.furman
Recipients David Rebbe2, eric.smith, ethan.furman, veky
Date 2021-08-24.20:43:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629837824.32.0.00591357302214.issue44993@roundup.psfhosted.org>
In-reply-to
Content
Firstly (or Zeroithly ;) my apologies for not noticing this earlier.


In the functional API section:
------------------------------
The reason for defaulting to 1 as the starting number and not 0 is that 0 is False in a boolean sense, but enum members all evaluate to True.

---

To the best of my knowledge, Python Enums are different from other languages' enums in several respects; apparently this is one of them.  Having the default first value be 1 has been there since the beginning, and isn't going to change now.

Rather than allowing numbers to be assigned using the function that says the assigned number doesn't matter, I would rather add `start=x` in the header, the way I have it in `aenum`:

    from aenum import Enum, auto

    class ZeroEnum(Enum, start=0):
        nothing = auto()
        something = auto()

    list(ZeroEnum)
    # [<ZeroEnum.nothing: 0>, <ZeroEnum.something: 1>]

    class ZeroBaseEnum(Enum, start=0):
        pass

    class ZeroEnum2(ZeroBaseEnum):
        nothing = auto()
        something = auto()

    list(ZeroEnum2)
    # [<ZeroEnum2.nothing: 0>, <ZeroEnum2.something: 1>]


Whether the `0` goes in the header, or in auto (which it isn't), people will still need to read the docs to find out about it (unless somebody asks an SO question, of course).
History
Date User Action Args
2021-08-24 20:43:44ethan.furmansetrecipients: + ethan.furman, eric.smith, veky, David Rebbe2
2021-08-24 20:43:44ethan.furmansetmessageid: <1629837824.32.0.00591357302214.issue44993@roundup.psfhosted.org>
2021-08-24 20:43:44ethan.furmanlinkissue44993 messages
2021-08-24 20:43:44ethan.furmancreate