Created
July 15, 2009 01:50
-
-
Save alexbeutel/147378 to your computer and use it in GitHub Desktop.
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/env python | |
# encoding: utf-8 | |
import sys | |
import random | |
import os | |
def clearscreen(numlines=100): | |
if os.name == "posix": | |
# Unix/Linux/MacOS/BSD/etc | |
os.system('clear') | |
elif os.name in ("nt", "dos", "ce"): | |
# DOS/Windows | |
os.system('CLS') | |
else: | |
print '\n' * numlines | |
def main(argv=None): | |
if argv is None: | |
argv = sys.argv | |
allLines = [] | |
again = 'x' | |
if(len(argv) > 2): | |
again = argv[2] | |
f = open(argv[1], 'r') | |
for line in f: | |
allLines.append(line) | |
clearscreen() | |
cnt = 0 | |
wrong = 0 | |
wWords = [] | |
while len(allLines) > 0: | |
cnt += 1 | |
l = allLines.pop(random.randint(0, len(allLines)-1)) | |
parts = l.split(":") | |
p = 1 | |
p2 = 0 | |
print cnt, "(", len(allLines), "). ", parts[p] | |
dummy = raw_input("") | |
if(dummy == "exit"): | |
break | |
print parts[p2] | |
dummy = raw_input("") | |
if(dummy == "exit"): | |
break | |
if(dummy == again): | |
allLines.append(l) | |
wrong += 1 | |
wWords.append(l.strip()) | |
clearscreen() | |
clearscreen() | |
print "Missed ", wrong, " times" | |
for line in wWords : | |
print line | |
if __name__ == "__main__": | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment