Petname

2.9 · active · verified Tue Apr 14

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.

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →