Skip to content

Instantly share code, notes, and snippets.

@xfxf
Last active August 3, 2016 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xfxf/3f37fb4d6d2bda98fb5876085117c47f to your computer and use it in GitHub Desktop.
Save xfxf/3f37fb4d6d2bda98fb5876085117c47f to your computer and use it in GitHub Desktop.
Read Pycon AU 2016 schedule, print out longest presenter & title names
#!/usr/bin/python
"""Read Pycon AU 2016 schedule, print out longest presenter & title names"""
import requests
SCHEDULE_JSON = 'https://2016.pycon-au.org/programme/schedule/json'
def get_presenter_title(schedule):
"""returns dict: {presenter: title}"""
result = requests.get(schedule, verify=False)
return {talk['Presenters']: talk['Title'] for talk in result.json() if 'Presenters' in talk}
def main():
talklist = get_presenter_title(SCHEDULE_JSON)
longest_presenter = max(talklist.keys(), key=len)
longest_title = max(talklist.values(), key=len)
print("({}) {}".format(len(longest_presenter), longest_presenter))
print("({}) {}".format(len(longest_title), longest_title))
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment