I find myself needing to iterate over a list made of dictionaries and I need, for every iteration, the name of which dictionary I\'m iterating on.
Here\'s an MWE (the co
Here's my solution for a descriptive error message.
def dict_key_needed(dictionary,key,msg='dictionary'): try: value = dictionary[key] return value except KeyError: raise KeyError(f"{msg} is missing key '{key}'")