Registry / devops / petname

petname

JSON →
library2.9pypypi✓ verified 84d ago

Petname is a Python library that generates human-readable, random names for objects by combining adverbs, adjectives, and common nouns. It's often used for generating unique hostnames or container names, providing memorable and pronounceable identifiers. The current version is 2.9, with a release cadence driven by bug fixes, security patches, and wordlist updates.

pip install petname
INSTALL
IMPORT
SIG · PETNAME
P
petname
devopspythonv2.9
Install
1.5s avg
Import
5ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.9 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.003s · 17.8MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.000s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

generate
import petname petname.generate()
from petname import PetName; PetName.generate()
The primary function `generate` is typically accessed directly as a method of the imported `petname` module, not from an instantiated class. Older examples might show a class or direct functions like `adverb()` or `name()`, but `generate()` is the main entry point for a full name.
Adjective
import petname petname.Adjective()
While `generate` is preferred for full names, individual word types can still be accessed directly.
Adverb
import petname petname.Adverb()
Individual word types can be accessed directly.
Name
import petname petname.Name()
Individual word types can be accessed directly.

Generate human-readable names with varying word counts and separators. The `generate()` function is the primary API. You can also access specific word types like adjectives, adverbs, or names directly.

import petname # Generate a two-word name (default) name1 = petname.generate() print(f"Generated name: {name1}") # Generate a three-word name with a custom separator name2 = petname.generate(3, '_') print(f"Generated name: {name2}") # Generate a single-word name with max letters name3 = petname.generate(1, max_letters=5) print(f"Generated name: {name3}") # Generate words from specific categories adjective = petname.Adjective() print(f"Random adjective: {adjective}")
petname --version
Debug
Known issues
breakingCritical DoS Vulnerability (CVE Candidate) in versions < 2.9: Word selection functions (`petname.adverb()`, `petname.adjective()`, `petname.name()`, and consequently `petname.generate()`) could hang indefinitely, consuming 100% CPU, if the `letters` (or `max_letters`) parameter was smaller than the shortest word in the internal word lists. For example, `petname.adverb(letters=3)` could cause an infinite loop in affected versions.
fix
Upgrade immediately to version 2.9 or newer: `pip install --upgrade petname`.
affects: < 2.9
gotchaWordlist changes in version 2.8: Several words (e.g., `peacock`, `cockatoo`, `woodcock`) were removed from the internal names list to maintain consistency with upstream versions and avoid potentially awkward or unprofessional combinations. If your application relied on the exact composition of previous wordlists, this change might subtly alter generated names.
fix
No direct fix needed unless specific word availability is critical; consider auditing generated names if this is a concern. If specific words are essential, external wordlists can be used via the `wordlist` parameter in `generate()`.
affects: 2.8, 2.9
gotchaThe `letters` parameter (now `max_letters` in `generate()`) can still lead to no names being found if constrained too strictly (e.g., `max_letters=1` when no single-letter words exist), resulting in an empty string or IndexError. While the infinite loop is fixed in 2.9, extreme constraints can still yield unexpected or empty results.
fix
Ensure that `max_letters` (or `letters` in older direct calls) is set to a reasonable value that allows for word selection. Test your name generation with chosen constraints.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'petname'
The 'petname' library is not installed in your current Python environment or the module name is misspelled.
fix
Install the library using pip: `pip install petname`
AttributeError: module 'petname' has no attribute 'generate'
You attempted to call a function or access an attribute named 'generate' (lowercase 'g'), but the primary name-generating function in the 'petname' library is 'Generate' (with an uppercase 'G').
fix
Use the correct function name: `petname.Generate()`
TypeError: Generate() missing 1 required positional argument: 'words'
The `petname.Generate()` function was called without providing a value for the 'words' argument, which specifies the number of words in the generated name and is often expected even if it has a default in some contexts.
fix
Provide the 'words' argument, e.g., `petname.Generate(words=2)`
ImportError: cannot import name 'generate' from 'petname'
You tried to import a specific function named 'generate' (lowercase 'g') directly from the 'petname' package, but the function is named 'Generate' (uppercase 'G') and is typically accessed as an attribute of the imported module, e.g., `petname.Generate`.
fix
Import the module itself and call the function, or correct the casing: `import petname; petname.Generate()` or `from petname import Generate` (if 'Generate' is explicitly exposed).
AttributeError: partially initialized module 'petname' has no attribute 'Generate'
A local Python file in your working directory is named 'petname.py', which 'shadows' the installed 'petname' library. Python imports your local file instead of the actual library, and your local file doesn't define the 'Generate' function.
fix
Rename your local Python file (e.g., from `petname.py` to `my_petname_script.py`) to avoid the name conflict.
Upgrade
Version history
2.9latest on PyPI · released Feb 15, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
5
Resources
petname — pip install petname · libregistry