[Python-ideas] Naming convention for Enums

Paul Moore p.f.moore at gmail.com
Wed Sep 14 07:58:53 EDT 2016


On 14 September 2016 at 12:51, Chris Angelico <rosuav at gmail.com> wrote:
> Perhaps the advice needs to be along the lines of: Decide what the
> purpose of the enum is, and follow a naming convention accordingly.
> Uppercase if you're basically making constants; lowercase if you're
> not; etcetera.

Agreed - it's not clear to me that a prescriptive rule has much
benefit here. The OP said "I believe that we need to make a decision
as no decision is somewhat worse and causes a lot of confusion" -
personally, I don't agree, I think it's fine to leave this to the
individual.

And of course, no matter how many times we stress that any rules we
add are "only recommendations", projects like pycodestyle will add
checks (as they should) and then projects that mandate a clean run of
a style checker will treat the rule as mandatory.

So I'm basically -1 on a PEP 8 rule at this stage, but if we have to
have one, I agree that it should say something along the lines of
"depends on how you're using the enum".

Paul

PS FWIW, I tend to think of enums as named constants, and so would
typically use uppercase, not lowercase. But I wouldn't like to impose
that on everyone :-)


More information about the Python-ideas mailing list