[Python-ideas] proper naming of Enum members

Ethan Furman ethan at stoneleaf.us
Mon Jul 18 13:22:50 EDT 2016


On 07/18/2016 09:53 AM, Matt Gilson wrote:

> 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.

Yeah, after I added the 'count_business_days' method I decided to break it apart as BusinessDays for the base behavior, and BankingHolidays for the members themselves; then it won't be US-centric.  I just haven't gotten that far.

--
~Ethan~


More information about the Python-ideas mailing list