[Python-ideas] Naming convention for Enums

Guido van Rossum guido at python.org
Thu Sep 15 14:26:10 EDT 2016


Please update the docs.

On Thu, Sep 15, 2016 at 11:14 AM, Chris Angelico <rosuav at gmail.com> wrote:
> On Fri, Sep 16, 2016 at 4:06 AM, Guido van Rossum <guido at python.org> wrote:
>>> Sometimes they function as integer constants (esp IntEnum), and
>>> sometimes more as just arbitrary values. See the examples in the docs
>>> [1] for Color and Mood, where the exact value is immaterial, just as
>>> long as Color.red is not Color.blue. Even though they happen to have
>>> integer values, they're not intended to be used as actual integers.
>>> For those cases, it's not as clear that they ought to be Color.RED and
>>> Color.BLUE - it's equally acceptable to have them in lowercase.
>>
>> I disagree. The whole point of an enum is to define a new *kind* of
>> constant. Clearly RED and BLUE are new constants. (The uppercase
>> convention is not just for giving names to literals -- that's not what
>> "constant" means.)
>
> Well, my view was largely colored [1] by the official docs. Your view
> is broadly the same as my ideal preference, just without the caveats
> and flexibility of accepting it the other way. So should the docs be
> updated to upper-case everything?
>
> With or without an actual PEP 8 change, that would send a strong
> message to the community. I'm sure I'm not the only person who looks
> at official examples as a style guide as well as a syntax demo.
>
> ChrisA
>
> [1] Sorry [2], that pun was just terrible
> [2] Actually I'm not sorry. But the pun was still terrible.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/



-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list