Last active 1478636627

Steven Smith revised this gist 1478672627. Go to revision

1 file changed, 14 insertions

elstate.py(file created)

@@ -0,0 +1,14 @@
1 + import urllib,json
2 + d=json.loads(urllib.urlopen("https://intf.nyt.com/newsgraphics/2016/11-08-election-forecast/president.json").read())["president"]
3 + print("""As of {timestamp}:
4 + Clinton:
5 + Votes: {electoral_votes_counted[clintonh]}/270
6 + Counted: {vote_share_counted[clintonh]:.3%}
7 + Win prob: {win_prob[clintonh]:.3%}
8 + Trump:
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]))
12 + print("\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"] ))
Newer Older