Created
April 4, 2013 15:01
-
-
Save super3/5311135 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
def generate_email(f_name, l_name): | |
"""Returns a random email.""" | |
common_email_providers = ["hotmail", "msn", "aol", "yahoo", "gmail"] | |
dictionary = file_to_list('data/dictionary.txt') | |
dictionary = small_dict(dictionary, 6) | |
user = "" | |
for i in range(3): | |
rand = random.randrange(1, 6) | |
if rand == 1: | |
user += f_name | |
elif rand == 2: | |
user += l_name | |
elif rand == 3: | |
user += random.choice(dictionary) | |
elif rand == 4: | |
user += random.choice(string.ascii_lowercase) | |
else: | |
user += str(random.randrange(1, 9999)) | |
email = user + "@" + random.choice(common_email_providers) + ".com" | |
# if too long or starts with number generate again | |
if len(email) > 30: | |
return generate_email(f_name, l_name) | |
elif email[0].isdigit(): | |
return generate_email(f_name, l_name) | |
else: | |
return email |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment