How to send dictionary values to a function

Question:

I have a Python dictionary assigned to a variable.

mpm_holidays = {
    "New Year's Day (Observed)": (None, True),
    "Martin Luther King Jr. Day": ("art/MLKDay.png", True),
    "2022-02-14": ("art/ValentinesDay.png", False),
    "Good Friday": ("art/GoodFriday.png", True),
    "2022-04-16": ("art/GoodFriday.png", True),
    "Memorial Day": ("art/MemorialDay.png", True),
    "2022-05-28": (None, True),
    "2022-06-19": ("art/Juneteenth.png", False),
    "Independence Day": ("art/IndependenceDay.png", True),
    "Independence Day (Observed)": (None, True),
    "Labor Day": ("art/LaborDay.png", True),
    "2022-09-03": (None, True),
    "2022-09-05": (None, True),
    "Veterans Day": ("art/VeteransDay.png", True),
    "Veterans Day (Observed)": (None, True),
    "2022-10-31": ("art/Halloween.png", False),
    "Thanksgiving": ("art/Thanksgiving.png", True),
    "Day After Thanksgiving": (None, True),
    "Christmas Eve": ("art/ChristmasEve.png", True),
    "Christmas Eve (Observed)": (None, True),
    "Christmas Day": ("art/ChristmasDay.png", True),
    "New Year's Eve": ("art/NewYearsEve.png", True)
}

I want to feed this variable’s values through a function I have:

def overlays(art_to_use_, closure_):
    """ Imprint closure and/or holiday artwork. """
    if art_to_use_:
        calendarSheet.paste(
            Image.open(art_to_use_).convert("RGBA"),
            (0, 0),
            mask=Image.open(art_to_use_).convert("RGBA")
        )
    if closure_:
        calendarSheet.paste(
            Image.open(STATUS_CLOSED).convert("RGBA"),
            (0, 0),
            mask=Image.open(STATUS_CLOSED).convert("RGBA")
        )
    calendarSheet.save(calendarSheetFilename, format="png")

What am I missing? How would I write this out?

I know that I’m not grasping something about how to map the values to the requisite parameters of the function.

Asked By: stunafish

||

Answers:

Loop over mpm_holidays.values() to get all the values.

for art, closed in mpm_holidays.values():
    overlays(art, closed)
Answered By: Barmar
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.