Skip to content

Instantly share code, notes, and snippets.

@rmax
Created March 27, 2010 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmax/346335 to your computer and use it in GitHub Desktop.
Save rmax/346335 to your computer and use it in GitHub Desktop.
from random import choice
MALE_NAMES_FILE = 'dist.male.first'
FEMALE_NAMES_FILE = 'dist.female.first'
LAST_NAMES_FILE = 'dist.all.last'
if __name__ == '__main__':
MALE_NAMES = list(line.split()[0] for line in open(MALE_NAMES_FILE))
FEMALE_NAMES = list(line.split()[0] for line in open(FEMALE_NAMES_FILE))
LAST_NAMES = list(line.split()[0] for line in open(LAST_NAMES_FILE))
randbool = lambda: choice((True, False))
randgender = lambda: choice((MALE_NAMES, FEMALE_NAMES))
for _ in range(100):
fullname = []
# gender for this name
GENDER_NAMES = randgender()
# choose first name
fullname.append(choice(GENDER_NAMES))
# maybe choose second name
if randbool():
fullname.append(choice(GENDER_NAMES))
# choose last name
fullname.append(choice(LAST_NAMES))
# maybe choose second last name
if randbool():
fullname.append(choice(LAST_NAMES))
# print capitalized
print ' '.join(map(str.capitalize, fullname))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment