Skip to main content

Nickname Generator

The Nickname Generator package provides simple functions to generate random nicknames.

Installation

pip install nickname-gen

Usage

This package provides two main methods for generating nicknames: get_random_en_nickname and get_random_ru_nickname.

get_random_en_nickname

Generates a random nickname in English.

from nickname_gen.generator import Generator
from nickname.gen.wtypes import WordList, WordType, Lang

# Using default parameters
nickname = Generator.get_random_en_nickname()
print(nickname)  # Example: 'Green Brave Tiger'

# Using a custom list of parts
my_adjectives = WordList("My Adjectives", Lang.EN, ["cool", "awesome"], WordType.ADJECTIVE)
my_nouns = WordList("My Nouns", Lang.EN, ["python", "developer"], WordType.NOUN)
nickname = Generator.get_random_en_nickname(combos=[my_adjectives, my_nouns])
print(nickname)  # Example: 'Awesome Developer'

# Using a custom separator
nickname = Generator.get_random_en_nickname(separator="-")
print(nickname)  # Example: 'Green-Brave-Tiger'

# Using a custom style
nickname = Generator.get_random_en_nickname(style=StyleEnum.UPPER)
print(nickname)  # Example: 'GREEN BRAVE TIGER'

This method can be customized by passing the following arguments:

  • combos (WordList object, optional): a list of parts to compose the nickname. By default, it uses the lists of adjectives, colors, and animals in English.
  • separator (string, optional): the separator between nickname parts. By default, it uses a space.
  • style (StyleEnum instance, optional): the style of the nickname. By default, it uses StyleEnum.CAPITAL. Available options:
    • StyleEnum.CAPITAL (the first letter of each word is capitalized),
    • StyleEnum.UPPER (all letters are uppercase),
    • StyleEnum.LOWER (all letters are lowercase).

get_random_ru_nickname

Generates a random nickname in Russian, considering the gender of the noun.

from nickname_gen import Generator

# Using default parameters
nickname = Generator.get_random_ru_nickname()
print(nickname)  # Example: 'Зеленый Храбрый Тигр' ('Green Brave Tiger')

# Using custom parameters (similar to the English version)
...

This method can be customized by passing the same arguments as for get_random_en_nickname.

Dependencies and Possible Errors

The nickname_gen library uses the following dependency:

  • pymorphy3 - for determining the gender of the noun when generating Russian nicknames.

When using the get_random_en_nickname and get_random_ru_nickname methods, the following exceptions may occur:

  • WordsAmountError: if there are fewer than one word in the list.
  • WordListAmountError: if there are fewer than two elements in the list of combinations.
  • WordListNounAmountError: if there is more than one list of nouns in the list of combinations.
  • LangError: if the languages of the word lists in the combinations differ.
  • WordTypeError: if the list of combinations does not contain lists of nouns and adjectives.
  • GenderNotFoundError: if the gender of the noun could not be determined (for Russian language only).

History and Inspiration

The idea for creating this package arose from the need to generate unique nicknames for one of my projects. Initially, I needed to generate random, but readable and memorable usernames.

Additional inspiration came from the user names and avatars that Google Docs assigns when collaborating on a document. They consist of an adjective and an animal name, such as "Unidentified Capybara," along with a random-colored icon of that animal. They are much more memorable than a set of random letters and numbers, but they do not accurately identify the user.

Based on this idea, I decided to create a package that would allow generating similar nicknames in different languages, while adding additional options to customize the format and style of the generated names, as well as the ability to use your own set of words. The result was the Nickname Generator package, which is now available for anyone to use.

Metadata

Release files for nickname-gen 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nickname-gen 0.1.5
File Size Uploaded
nickname_gen-0.1.5.tar.gz 13.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nickname-gen 0.1.5
File Interpreter ABI Platform
nickname_gen-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 34.3 kB

Release files / nickname_gen-0.1.5.tar.gz

Download URL nickname_gen-0.1.5.tar.gz
Size 13.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a1b412774faa880b896ab5a3d9bf2a7adb4a9a7f427c142ed44b04eb9bff5386
BLAKE2b-256 checksum
How to use checksums
796c6df47fdd3c2d54645bf07f5dd593834e675893567e32b4fb7a9ca8e4e65c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.3 Windows/11

Release files / nickname_gen-0.1.5-py3-none-any.whl

Download URL nickname_gen-0.1.5-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
698407b30678d1968a03f3bb8b1a97e229d6cd8fc00e83e016a89ce836fe0cd0
BLAKE2b-256 checksum
How to use checksums
268ad2f3b20264b49274150422518ee0481ff80f6e3dd0f039d6f73701530eba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.12.3 Windows/11

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page