Created
November 18, 2012 04:11
-
-
Save sennajox/4103476 to your computer and use it in GitHub Desktop.
Create a simple list containing random strings
This file contains hidden or 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 | |
import sys, os | |
import string | |
import random | |
def id_generator(size=6, chars=string.ascii_uppercase): | |
return ''.join(random.choice(chars) for x in range(size)) | |
if __name__ == "__main__": | |
argc = len(sys.argv) | |
if argc < 3: | |
print "usage: %s file count" % sys.argv[0] | |
exit(1) | |
file = open(sys.argv[1], 'w') | |
count = int(sys.argv[2]) | |
for i in range(0, count): | |
str = id_generator(25) | |
str += "\n" | |
#print str | |
file.write(str) | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment