Skip to content

Commit

Permalink
Random names on a separated file
Browse files Browse the repository at this point in the history
  • Loading branch information
jbvsmo committed Apr 18, 2014
1 parent 88ec098 commit 82dfaeb
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 13 deletions.
48 changes: 48 additions & 0 deletions data/random_names.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Bob
Juan
Red
Blue
Oak
Mega Mewtwo X
Ray Charles
Jesse Pinkman
Walter White
Pikachu
Gary
Ash
Suzy
Misty
Brock
Punk
Tarzan
Smeagol
Ricardão
Hodor
Joffrey
Bruce Wayne
Wolverine
Mendigo
Capitão Caverna
Xuxa
Ted
Barney
Marshall
Lily
Robin
Batman
Gandalf
Frodo
Bilbo
Smaug
Garbodor
ABBBBBBK(
Jay Leno
Zapdos
Helix Fossil
Poochyena
Patrick
Jennifer Lawrence
AJ
Sherlock Holmes
Samuel L. Jackson
Yo Mama
17 changes: 4 additions & 13 deletions randomness.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
import random
import string

with open('data/random_names.txt', 'rb') as file:
random_names = file.read().decode('utf-8').strip().splitlines()


def name(size, letters=string.ascii_lowercase):
return ''.join(random.choice(letters) for _ in range(size))


def select_name(do_not=(), size_random=7):
names = (
'Bob', 'Juan', 'Red', 'Blue', 'Oak', 'Mega Mewtwo X',
'Ray Charles', 'Jesse Pinkman', 'Walter White', 'Pikachu',
'Gary', 'Ash', 'Suzy', 'Misty', 'Brock', 'Punk', 'Tarzan',
'Smeagol', 'Ricardão', 'Hodor', 'Joffrey', 'Bruce Wayne',
'Wolverine', 'Mendigo', 'Capitão Caverna', 'Xuxa',
'Ted', 'Barney', 'Marshall', 'Lily', 'Robin', 'Batman',
'Gandalf', 'Frodo', 'Bilbo', 'Smaug', 'Garbodor',
'ABBBBBBK(', 'Jay Leno', 'Zapdos', 'Helix Fossil',
'Poochyena', 'Patrick', 'Jennifer Lawrence', 'AJ',
'Sherlock Holmes', 'Samuel L. Jackson', 'Yo Mama',
)
for _ in range(5):
n = random.choice(names)
n = random.choice(random_names)
if n not in do_not:
return n
return name(size_random)

0 comments on commit 82dfaeb

Please sign in to comment.