Created
February 21, 2023 01:27
-
-
Save amakukha/f80c96012dea9af23db2d9dc41c8e4d2 to your computer and use it in GitHub Desktop.
Generate unique random strings or identifiers
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
#!/usr/bin/env python3 | |
'''Generate unique random strings or identifiers''' | |
import random, sys | |
# How many new unique identifiers to generate? | |
NUMBER = 100 if len(sys.argv) <= 1 else int(sys.argv[1]) | |
# How many words to combine into a new generated string? | |
LENGTH = 3 if len(sys.argv) <= 2 else int(sys.argv[2]) | |
# List of agricultural words | |
vocabulary_string = '''acre acreage agriculture almond animals apple apricot avocado | |
bale baler banana barley barn bean bee beehive bison blueberry boar bread breed broccoli bucket buckwheat buffalo bull butter | |
cabbage calf cat cattle cherry chick chicken chickpea cocoa coconut combine compost coop corn cow crops crow cucumber cultivator cheese | |
dairy dates dill dog donkey drake duck duckling | |
eggs ewe | |
fallow farm farmer farmhouse feed fence field flock foal food fruit | |
gander garlic gate geese ginger goat goose gooseberry grains grape greenhouse grow | |
harvest harvester hatchery hay haystack hen herd hive hoe hog honey honeybee horse | |
irrigation | |
jenny jersey | |
kiwi | |
lamb land lemon legumes lentils lettuce llama longhorn | |
machete maize malt mango mare meadow milk mower mulch mule | |
oats olive onion orange orchard organic ox | |
pail papaya parsley pasture pea pear pick pickaxe pickle pie pig piglet pineapple plant plow plum pomegranate potato poult poultry pumpkin pullet | |
quinoa | |
rabbit raisins rake ram ranch reap rice ripe roost rooster rye | |
sauerkraut scarecrow scythe seeds sesame shears sheep shepherd shovel sickle silo soil soy sow stable stallion steer strawberry swine sugar | |
tend tiller tomato tractor trough trowel turkey turnip | |
udder | |
vegetable | |
water watermelon weeder wheat windmill wood | |
yak | |
cashew chestnut coconut hazelnut macadamia peanut pecan pistachio walnut''' | |
vocabulary = vocabulary_string.split() | |
generated = set() | |
for i in range(NUMBER): | |
while True: | |
random.shuffle(vocabulary) | |
name = '_'.join(vocabulary[:LENGTH]) | |
if name not in generated: | |
generated.add(name) | |
print(name) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment