3 examples of 'random names list' in Python

Every line of 'random names list' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
20def get_random_name(names_list, size=1):
21 return names_list[random.randrange(0, len(names_list))]
9def get_random_name(names_list, size=1):
10 name_lst = [names_list[random.randrange(0, len(names_list))].decode("utf-8").capitalize() for i in range(0, size)]
11 return " ".join(name_lst)
168def gen_names():
169 num_fgs = 431
170 num_bgs = 43100
171 num_bgs_per_fg = 100
172
173 names = []
174 bcount = 0
175 for fcount in range(num_fgs):
176 for i in range(num_bgs_per_fg):
177 names.append(str(fcount) + '_' + str(bcount) + '.png')
178 bcount += 1
179
180 valid_names = random.sample(names, num_valid)
181 train_names = [n for n in names if n not in valid_names]
182
183 with open('valid_names.txt', 'w') as file:
184 file.write('\n'.join(valid_names))
185
186 with open('train_names.txt', 'w') as file:
187 file.write('\n'.join(train_names))

Related snippets