Skip to content

Instantly share code, notes, and snippets.

@uhbif19
Created December 8, 2011 15:55
Show Gist options
  • Save uhbif19/1447408 to your computer and use it in GitHub Desktop.
Save uhbif19/1447408 to your computer and use it in GitHub Desktop.
Генерация случайных ников
def random_nick():
""" Сгенерировать ник (имя юзера). [Модификация: http://codepaste.ru/3853/]"""
vowels = 'aeuioy'
covowels = 'qwrtpsdfghjklzxcvbnm'
syllables = [[], []]
# Состовляем таблицу возможных
for vowel in vowels :
for covowel in covowels :
if vowel != 'y':
syllables[0].append(vowel + covowel)
syllables[1].append(covowel + vowel)
nick = "" # Сам ник
d = True
for i in xrange(0, random.randint(3, 4)):
# Строим слово по слогам
d = not d
nick += random.choice( syllables[int(d)] )
d = random.randint(0, 9) > 7 or nick[-1] == 'y'
if random.randint(0, 9) > 4:
# Добавляем последнию букву
c = d and covowels or vowels
nick += random.choice( c )
return nick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment