Last active 1478636627

elstate.py Raw
1import urllib,json
2d=json.loads(urllib.urlopen("https://intf.nyt.com/newsgraphics/2016/11-08-election-forecast/president.json").read())["president"]
3print("""As of {timestamp}:
4Clinton:
5 Votes: {electoral_votes_counted[clintonh]}/270
6 Counted: {vote_share_counted[clintonh]:.3%}
7 Win prob: {win_prob[clintonh]:.3%}
8Trump:
9 Votes: {electoral_votes_counted[trumpd]}/270
10 Counted: {vote_share_counted[trumpd]:.3%}
11 Win prob: {win_prob[trumpd]:.3%}""".format(**d["timeseries"][-1]))
12print("\n".join( "{state}: {current[winner][name_display]}".format(**s) if s["current"]["winner"] else
13 "{state}: Undecided, {current[percent_counted]:.1%} counted - Clinton: {current[win_prob][clintonh]:.1%}, Trump: {current[win_prob][trumpd]:.1%}".format(**s)
14 for s in d["races"] ))