<div dir="ltr">I also generally think of Enum as a collection of constants so I favor CAP_WORDS for enum members.  I will admit that my answer is biased in that I don't typically create Enums that have a whole bunch of methods as you've done in your example.  For your example code, I might separate it out into two classes (something representing a Date and an enum representing a Holidays).  The former class could use the latter to compute things like "Next business day", etc.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 18, 2016 at 8:41 AM, Guido van Rossum <span dir="ltr"><<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Honestly my own preference would be to use UPPER_CASE, emphasizing the<br>
const-ness. CapWords is really only used for classes, which are<br>
entirely different beasts. And lower_case is for methods and<br>
variables. I think it's useful to emphasize that an enum is neither.<br>
<div class="HOEnZb"><div class="h5"><br>
On Mon, Jul 18, 2016 at 8:17 AM, Ethan Furman <<a href="mailto:ethan@stoneleaf.us">ethan@stoneleaf.us</a>> wrote:<br>
> There are currently a few locations in the stdlib, such as http and socket,<br>
> that are now using<br>
> Enums to replace constants; those names are all upper-case -- those aren't<br>
> the names I am<br>
> speaking of.<br>
><br>
> The names I am speaking of are those in brand-new enumerations where we have<br>
> full control.<br>
><br>
> As an example:<br>
><br>
> class FederalHoliday(AutoNumberEnum):<br>
>     NewYear = "First day of the year.", 'absolute', JANUARY, 1<br>
>     MartinLutherKingJr = "Birth of Civil Rights leader.", 'relative',<br>
> JANUARY, MONDAY, 3<br>
>     President = "Birth of George Washington", 'relative', FEBRUARY, MONDAY,<br>
> 3<br>
>     Memorial = "Memory of fallen soldiers", 'relative', MAY, MONDAY, 5<br>
>     Independence = "Declaration of Independence", 'absolute', JULY, 4<br>
>     Labor = "American Labor Movement", 'relative', SEPTEMBER, MONDAY, 1<br>
>     Columbus = "Americas discovered", 'relative', OCTOBER, MONDAY, 2<br>
>     Veterans = "Recognition of Armed Forces service", 'relative', NOVEMBER,<br>
> 11, 1<br>
>     Thanksgiving = "Day of Thanks", 'relative', NOVEMBER, THURSDAY, 4<br>
>     Christmas = "Birth of Jesus Christ", 'absolute', DECEMBER, 25<br>
><br>
>     def __init__(self, doc, type, month, day, occurance=None):<br>
>         self.__doc__ = doc<br>
>         self.type = type<br>
>         self.month = month<br>
>         self.day = day<br>
>         self.occurance = occurance<br>
><br>
>     def date(self, year):<br>
>         """<br>
>         returns the observed date of the holiday for `year`<br>
>         """"<br>
>         ...<br>
><br>
>     @classmethod<br>
>     def next_business_day(cls, date, days=1):<br>
>         """<br>
>         Return the next `days` business day from date.<br>
>         """<br>
>         ...<br>
>     @classmethod<br>
>     def count_business_days(cls, date1, date2):<br>
>         """<br>
>         Return the number of business days between 'date1' and 'date2'.<br>
>         """<br>
>         ...<br>
>     @classmethod<br>
>     def year(cls, year):<br>
>         """<br>
>         Return a list of the actual FederalHoliday dates for `year`.<br>
>         """<br>
>         ...<br>
> Take the name "NewYear":  if it had been a global constant I would have<br>
> named it "NEWYEAR"; if<br>
> it had been a normal class attribute I would have named it "new_year";<br>
> however, being an Enum<br>
> member, it is neither of those things.<br>
><br>
> <context switch><br>
> I've written some custom data types as part of my dbf package, and a few of<br>
> them have instances<br>
> that are singletons that are created in the global (okay, module) namespace,<br>
> and for them I<br>
> followed Python's lead in naming singletons:  Python has used Title Case in<br>
> such things as None,<br>
> True, and False, so I followed suit and named mine -- Null, NullDate,<br>
> NullTime, NullDateTime, etc.<br>
> </context switch><br>
><br>
> Given my past history with using and creating singleton objects, I followed<br>
> suit when creating<br>
> my own Enum classes.<br>
><br>
> I was recently queried about my apparent break with PEP 8 for naming Enum<br>
> members, to which I<br>
> replied:<br>
><br>
>> Considering the strange beast that an Enum is, there is not much precedent<br>
>> for it anywhere.<br>
>><br>
>> Consider:<br>
>><br>
>> - Enum is a class<br>
>> -   but it is a container<br>
>> -   and can be iterated over<br>
>> -   and it has a length (which can be zero)<br>
>> -   but it's always True in a boolean sense<br>
>><br>
>> - Enum members are instances of the Enum class<br>
>> -   but are pre-created<br>
>> -   and new ones cannot be created<br>
>> -   but are available as attributes on the class<br>
>><br>
>> Given all that I have been using Title case (or CamelCase) to name the<br>
>> members as it helps<br>
>> distinguish an Enum member from an ordinary attribute (which Enum classes<br>
>> can also have).<br>
><br>
><br>
> I forgot to include in that reply that I think CamelCase also helps to<br>
> emphasize the special<br>
> singleton nature of Enum members.<br>
><br>
> My question for the community:  Your thoughts/opinions of my reasoning, and<br>
> if you don't agree<br>
> then which casing choice would you recommend and use, and why?  (Reminder:<br>
> this question does<br>
> not include Enums whose names are replacements for existing constants and so<br>
> the names cannot<br>
> be changed.)<br>
><br>
> --<br>
> ~Ethan~<br>
> _______________________________________________<br>
> Python-ideas mailing list<br>
> <a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
> <a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
> Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
--Guido van Rossum (<a href="http://python.org/~guido" rel="noreferrer" target="_blank">python.org/~guido</a>)<br>
</font></span><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><span><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:14.6667px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><img src="https://lh6.googleusercontent.com/KjKhxPuGD6aSETVh9dazBSiS5FGrt8b37DYQ6QZAxpJIomTEygFF6ygbgOUbR0MBzycO8-LF-FspB3wTJb8LXEfIbJ6lN4H2J04EYzOZg7uaG7YcGkWesdldHuXzhLwS-etJBGO6" width="95" height="26" style="border:none" alt="pattern-sig.png"></span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10.6667px;font-family:Arial;color:rgb(102,102,102);font-weight:700;vertical-align:baseline;white-space:pre-wrap">Matt Gilson</span><span style="font-size:10.6667px;font-family:Arial;color:rgb(102,102,102);vertical-align:baseline;white-space:pre-wrap"> // SOFTWARE ENGINEER</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10.6667px;font-family:Arial;color:rgb(153,153,153);vertical-align:baseline;white-space:pre-wrap">E: </span><span style="font-size:10.6667px;font-family:Arial;color:rgb(17,85,204);vertical-align:baseline;white-space:pre-wrap"><a href="mailto:matt@getpattern.com" target="_blank">matt@getpattern.com</a></span><span style="font-size:10.6667px;font-family:Arial;color:rgb(153,153,153);vertical-align:baseline;white-space:pre-wrap"> // P: 603.892.7736</span></p><br><span style="font-size:12px;font-family:Arial;color:rgb(255,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">We’re looking for beta testers.  Go </span><a href="https://www.getpattern.com/meetpattern" style="text-decoration:none" target="_blank"><span style="font-size:12px;font-family:Arial;color:rgb(17,85,204);text-decoration:underline;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">here</span></a><span style="font-size:12px;font-family:Arial;color:rgb(255,0,0);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"> to sign up!</span></span><br></div></div>
</div>