I have a method that accepts a dict as an input and does some formatting on the dict.
I would like to ensure the dict contains the required entries before starting the formatting. At the moment I have the code
if not ('email' in payload and
'renewal_date' in payload and
'username' in payload
):
raise InvalidDictContentsError
Some of the dicts will have 15 or so items in it so it gets very long. Is there a more elegant way of verifying the dict?