Last active
August 3, 2016 11:25
-
-
Save xfxf/3f37fb4d6d2bda98fb5876085117c47f to your computer and use it in GitHub Desktop.
Read Pycon AU 2016 schedule, print out longest presenter & title names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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