Title: PEP0435 (enums) -- there is no standard on enum item letters case
Type: Stage:
Components: Documentation Versions: Python 3.10, Python 3.9, Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: DahlitzFlorian, barry, docs@python, eli.bendersky, ethan.furman, remi.lapeyre, socketpair
Priority: normal Keywords:

Created on 2020-05-21 21:42 by socketpair, last changed 2020-05-22 08:12 by xtreak.

Messages (4)
msg369544 - (view) Author: Марк Коренберг (socketpair) * Date: 2020-05-21 21:42
Example from PEP0435:


>>> from enum import Enum
>>> class Color(Enum):
...     red = 1
...     green = 2
...     blue = 3

Example from Python documentation:


>>> from enum import Enum
>>> class Color(Enum):
...     RED = 1
...     GREEN = 2
...     BLUE = 3

So, what are the rules for naming enum members?
CamelCase ? snake_case ? ALL_CAPS ?

Someone should explain how should we format sources. So various linters may check for that.
msg369545 - (view) Author: Марк Коренберг (socketpair) * Date: 2020-05-21 21:44
FYI: PEP8 does not mention enums.
msg369546 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2020-05-21 21:50
There is no official way, you can find both in the Python tree: all caps at and snake case at

I think it's common to use all caps for those that are used as flags (i.e. where each value is a power of 2 and that may be combined using bigs operations) but there is no one true way that you can enforced, it depends on the context. 

Also, note that pep8 covers the code of Python, it's not a rule that must be blindly applied to all Python code and that you may ignore it for various reasons:
msg369565 - (view) Author: Florian Dahlitz (DahlitzFlorian) * Date: 2020-05-22 08:10
Should we add a note that there is no preferred way of naming enum members and provide a few examples or define some naming conventions?
Date User Action Args
2020-05-22 08:12:54xtreaksetnosy: + barry, eli.bendersky, ethan.furman
2020-05-22 08:10:06DahlitzFloriansetnosy: + DahlitzFlorian
messages: + msg369565
2020-05-21 21:50:03remi.lapeyresetnosy: + remi.lapeyre
messages: + msg369546
2020-05-21 21:44:35socketpairsetmessages: + msg369545
2020-05-21 21:42:56socketpaircreate