python raise error if key not in dict