Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=====================================#
- #==============MODULES================#
- #=====================================#
- import itertools
- #=====================================#
- #==============VARIABLES==============#
- #=====================================#
- alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()_+-={}|[]\:';,./<>? "
- #=====================================#
- #==============FUNCTIONS==============#
- #=====================================#
- #defines algorithm to create words list
- def wordlist(alpha):
- for n in itertools.count(1):
- for word in itertools.product(alpha, repeat = n):
- yield ''.join(word)
- #creates output file and writes list to file
- def buffer_function(filename, alpha, max_words):
- file = open(filename, "w")
- buffer = ""
- buffer = list(itertools.islice(wordlist(alpha), max_words))
- for word in buffer:
- file.write("%s\n" % word)
- print "Word List '%s' Created" % filename
- file.close()
- buffer = ""
- #=====================================#
- #=============MAIN PROGRAM============#
- #=====================================#
- def main():
- print "This program generates a word list using a pre-defined alphabet and writes the output to a file."
- print
- print
- max_words = input("Maximum number of words in list: ")
- filename = raw_input("Enter a filename to save the word list as: ") + ".txt"
- buffer_function(filename, alpha, max_words)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement