Skip to content

Instantly share code, notes, and snippets.

@colinpollock
Created September 21, 2012 23:30
Show Gist options
  • Save colinpollock/3764500 to your computer and use it in GitHub Desktop.
Save colinpollock/3764500 to your computer and use it in GitHub Desktop.
Code for running Friday Shots and persisting winner/loser results
from datetime import datetime
import json
import random
import sys
names = list(set(sys.argv[1:]))
print 'There are %d players: %s' % (len(names), ', '.join(sorted(names)))
raw_input('Continue?')
random.shuffle(names)
results = {}
for index, name in enumerate(names):
result = raw_input('[%d] %s: ' % (index, name))
if result.lower() in ('y', 't', '1'):
results[name] = True
elif result.lower() == 'skip':
continue
else:
results[name] = False
with open('results.json', 'r') as f:
data = json.load(f)
data.append({'date': str(datetime.now().date()), 'results': results})
with open('results.json', 'w') as f:
json.dump(data, f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment