
"We keep a list of meals we try out. Each family member assigns a score to each meal. Every Saturday, before we go to the supermarket for the weekly shop, we plan which meals we'll cook on each day of the week. It's not based solely on the preference ratings, of course, since my wife and I have the final say to ensure a good balance. Finally, the program provides us with the shopping list with the ingredients we need for all the week's meals."
"The ._meals data attribute is a dictionary with the days of the week as keys and Meal instances as values. It's defined as a non-public attribute to be used with the read-only property.meals. The .meals property returns a shallow copy of the ._meals dictionary. This makes it safer as it's harder for a user to make changes directly to this dictionary. The dictionary is modified only through methods within WeeklyMealPlanner."
Family uses a Python program to plan meals for the week and generate a shopping list. A maintained list of meals receives preference scores from each family member. Planning occurs every Saturday before the weekly supermarket shop, balancing ratings with parental decisions. Busy days are flagged with a quick_meal Boolean to identify quick recipes. A WeeklyMealPlanner class stores selected meals in a non-public ._meals dictionary keyed by weekdays and holding Meal instances. A read-only .meals property returns a shallow copy of ._meals to prevent direct external modification. The dictionary is changed only by WeeklyMealPlanner methods. The code emphasizes alternative constructors implemented as class methods.
Read at Thepythoncodingstack
Unable to calculate read time
Collection
[
|
...
]