I have defined a class which uses a constructor that's meant to allow any number of a set of properties be attributed:
class CalendarEvent:
"""Represents a macOS calendar event."""
def __init__(self, **keyword_arguments):
self.__allowed_properties = ["starts", "ends", "repeat", "end_repeat", "travel_time", "alert", "notes", "invitees"]
for key, value in keyword_arguments:
if key in self.__allowed_properties:
setattr(self, key, value)
When I try to create a CalendarEvent
though,
party_tomorrow = CalendarEvent(
starts = datetime.datetime.today() + datetime.timedelta(days = 1),
ends = datetime.datetime.today() + datetime.timedelta(days = 1, hours = 5),
repeat = None,
end_repeat = None,
travel_time = datetime.timedelta(hours = 1),
alert = None,
notes = "This is gonna be a load of fun.",
invitees = None
)
I get the error:
Traceback (most recent call last):
File "/Users/George/Library/FlashlightPlugins/calendarquery.bundle/plugin.py", line 62, in test_CalendarEvent
invitees = None
File "/Users/George/Library/FlashlightPlugins/calendarquery.bundle/plugin.py", line 12, in __init__
for key, value in keyword_arguments:
ValueError: too many values to unpack (expected 2)