My aim is to assign a color to each workday in a week. So if a user enters a day as a str, then I can know which color it should have.
Because colors and workdays are fixed, I make them as enum.Enum instance.
- Is
enum.Enuma proper choice for colors and workdays? - To link day and color, I choose dictionary for
weekday_color. Is there a better choice?
from enum import Enum class WeekDay(Enum): MONDAY = 'Monday' TUESDAY = 'Tuesday' WEDNESDAY = 'Wednesday' THURSDAY = 'Thursday' FRIDAY = 'Friday' class Color(Enum): RED = 'Red' GREEN = 'Green' BLUE = 'Blue' weekday_color = { WeekDay.MONDAY: Color.RED, WeekDay.TUESDAY: Color.GREEN, WeekDay.WEDNESDAY: Color.BLUE, WeekDay.THURSDAY: Color.GREEN, WeekDay.FRIDAY: Color.RED, } def main(): today_input = 'Monday' today = WeekDay(today_input) today_color = weekday_color[today] print(today) print(today_color) if __name__ == '__main__': main()
weekday_colorseems to indicate a single element with a single color.weekday_colorschemeorcolorscheme_for_weekdaysmaybe? \$\endgroup\$