Skip to content

Instantly share code, notes, and snippets.

@btc
Created April 9, 2012 21:04
Show Gist options
  • Save btc/2346524 to your computer and use it in GitHub Desktop.
Save btc/2346524 to your computer and use it in GitHub Desktop.
Creates file of test fragments for cs107/assn1
import string
import random
def mkfrag(N):
body = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(N))
return "#" + body + "#"
if __name__ == '__main__':
nfrags = input('how many frags? ')
fraglength = input('frag length: ')
filename = raw_input('enter filename to write: ')
file = open(filename,"w")
for i in range(nfrags):
file.write(mkfrag(fraglength))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment