Skip to content

Instantly share code, notes, and snippets.

@miroli
Created March 7, 2015 22:23
Show Gist options
  • Save miroli/f00d501232436fd4e691 to your computer and use it in GitHub Desktop.
Save miroli/f00d501232436fd4e691 to your computer and use it in GitHub Desktop.
def generate_results(results_list):
"""
Generate an iterator of Result objects from a list of dictionary
containing result attributes
Args:
results_list: An iterable of dictionaries representing election
results. Each dictionary should have at least the following
keys: `candidate_name`, `candidate_id`, and `total_votes`.
Returns:
An iterator over Result objects created from the attributes in
results_list
"""
# TODO: Implement this generator
for result in results_list:
yield Result(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment