Haikunator

raw JSON →
2.1.0 verified Mon Apr 27 auth: no python

Haikunator is a Heroku-like random name generator for Python. It produces combinations of adjectives, nouns, and random numbers or hex values. Version 2.1.0 is current; the library is stable with infrequent releases.

pip install haikunator
error AttributeError: module 'haikunator' has no attribute 'Haikunator'
cause Incorrect import due to misspelling or wrong casing.
fix
Use: from haikunator import Haikunator
error ImportError: cannot import name 'haikunator' from 'haikunator'
cause Attempting to import haikunator directly instead of Haikunator class.
fix
Use: from haikunator import Haikunator
error ValueError: token_hex must be a bool
cause Passing integer or string to token_hex parameter.
fix
Set token_hex=True or token_hex=False.
breaking In v2.0.0, the 'token_hex' parameter was added and the default token length changed from 4 to 4 hex digits. Existing code relying on numeric token default may produce different output.
fix Specify token_hex=False and token_length=4 to restore old behavior if needed.
gotcha Haikunator is not thread-safe. Shared instances across threads may produce duplicates.
fix Create a new Haikunator instance per thread or per call.
deprecated The 'token_hex' parameter defaults to True in v2.1.0. If you rely on numeric tokens, set token_hex=False explicitly to ensure forward compatibility.
fix Use token_hex=False for numeric tokens.

Generate a random name using default settings (adjective-noun-token).

from haikunator import Haikunator

h = Haikunator()
name = h.haikunate()
print(name)  # e.g., 'bold-cloud-1234'