Created
December 8, 2011 15:55
-
-
Save uhbif19/1447408 to your computer and use it in GitHub Desktop.
Генерация случайных ников
This file contains hidden or 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 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