A Python package and command-line utility to generate unique and memorable names (e.g., talented-toucan, naughty-watermelon) and IDs (e.g., broken-radio-7ab4g). These names/IDs are ideal for naming temporary directories, user session IDs, gamer tags, project names, process names, or submitted jobs.
The generated names cover a wide range of thematic categories, including science, animals, or history, often with a humorous twist. While creating unique-namer, I was inspired by the creative names used by Docker for its containers and Nextflow for its processes.
Categories allow you to customize generated names to fit the specific topic or theme of your project. The default category, general, includes widely recognized nouns and excludes more specialized or uncommon terms.
If you prefer to use unique-namer without installation, you can clone or download the repository:
git clone https://github.com/aziele/unique-namer.git
cd unique-namer/src/
You can import namer in Python:
python
>>> import namer
>>> namer.__doc__
'Generate unique, human-readable, and memorable names or identifiers'
You can also use unique-namer as a command-line tool:
python -m namer
5. Usage
5.1. Generating names
The generate function returns a string with a randomly generated name consisting of an adjective and a noun.
import namer
name = namer.generate()
print(name) # Example: 'blushy-cyclist'
category - str or list, default is general
The generate function selects nouns from the general category by default. If category is provided as a list of categories, the function randomly chooses one category from the list to generate a noun. Each category is chosen with equal probability, regardless of the number of nouns it contains.
import namer
name = namer.generate(category='astronomy')
print(name) # Example: 'crazy-supernova'
name = namer.generate(category=['physics', 'biology'])
print(name) # Example: 'pink-bacteria'
To use all available categories, set the category argument to __all__.
import namer
name = namer.generate(category='__all__')
print(name) # Example: 'lonely-momentum'
suffix_length - int, default is 0
Adds a random suffix of the specified length to the generated name to create a unique identifier. The suffix consists of alphanumeric characters (0-9a-z).
import namer
name = namer.generate(category='history', suffix_length=3)
print(name) # Example: 'annoying-cleopatra-9a1'
separator - str, default is '-'
Specifies the separator to use between the adjective, noun, and suffix in the generated name.
import namer
name = namer.generate(category='sports', separator='_')
print(name) # Example: 'savage_judo'
style - str, one of title, lowercase, uppercase
Specifies the text case format of the generated name.
import namer
name = namer.generate(suffix_length=5, style='uppercase')
print(name) # Example: 'DAMAGED-ELECTRON-J20ZX'
name = namer.generate(separator=' ', style='title')
print(name) # Example: 'Lazy Unicorn'
5.2. Customizing names
To tailor the generated names to your specific project needs, such as adding a date or project name, use the _generate function. This function returns a Python list of name components and a separator. You can modify the list and then format it into a string.
To generate names or IDs tailored to your project, you can add custom categories. Extend the namer.data.categories dictionary with lists of words representing your custom category.
import namer
# Create two subcategories.
my_dogs = ['charlie', 'bella', 'biga']
my_cats = ['tommy', 'lucy']
# Add a custom category named 'my_pets' containing both dogs and cats
namer.data.categories['my_pets'] = [my_dogs, my_cats]
# Generate a name from the 'my_pets' category
name = namer.generate(category='pets')
print(name) # Example: 'thankful-tommy'
6. Command-line utility
The tool is available as a command-line utility.
namer -h
or
python -m namer -h
6.1. Getting statistics
The stats command prints a table with name/ID statitics for each category.
Example 2: Generating 10 IDs with custom parameters
To generate 10 IDs from the physics and biology categories, with a random suffix of 3 characters, using _ as a separator, and converting name style to title, use