Classes and functions

Functions and methods accept and return Unicode strings, that is, unicode in Python 2 and str in Python 3.

Default generator

coolname.generate(pattern=None)

Returns a random sequence as a list of strings.

Parameters:pattern (int) – Can be 2, 3 or 4.
Return type:list of strings
coolname.generate_slug(pattern=None)

Same as generate(), but returns a slug as a string.

Parameters:pattern (int) – Can be 2, 3 or 4.
Return type:str
coolname.get_combinations_count(pattern=None)

Returns the number of possible combinations.

Parameters:pattern (int) – Can be 2, 3 or 4.
Return type:int
coolname.replace_random(random)

Replaces the random number generator. It doesn’t affect custom generators.

Parameters:randomrandom.Random instance.

Custom generators

class coolname.RandomGenerator(config, random=None)
Parameters:
  • config (dict) – Custom configuration dictionary.
  • randomrandom.Random instance. If not provided, random.randrange() will be used.
generate(pattern=None)

Returns a random sequence as a list of strings.

Parameters:pattern – Not applicable by default. Can be configured.
Return type:list of strings
generate_slug(pattern=None)

Same as generate(), but returns a slug as a string.

Parameters:pattern – Not applicable by default. Can be configured.
Return type:str
get_combinations_count(pattern=None)

Returns the number of possible combinations.

Parameters:pattern – Not applicable by default. Can be configured.
Return type:int