Created
December 1, 2013 23:23
-
-
Save asottile/7742195 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
import random | |
import re | |
simple_word_regex = re.compile('^[a-z]+$') | |
word_list = [] | |
with open('/usr/share/dict/american-english', 'r') as words_file: | |
for word_line in words_file: | |
word = word_line.strip() | |
if simple_word_regex.match(word): | |
word_list.append(word) | |
def generate_password(length=4): | |
return ' '.join( | |
word_list[random.randint(0, len(word_list))] | |
for _ in xrange(length) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment