Skip to main content

A random name generator

Project description

NickNamer

NickNamer is a Python library for generating random names.

There are two options for random generation. The first is a random sequence of words that can be included with a defined format. The format is a string using tags for the available word types. A format string of "-" will return a string with a noun and a verb, separated by a dash. For example: 'car-run' or 'chair-talk'. Valid word type tags are: "", "", and "".

The second option is a string of random letters (both capital and lower case) and digits. The length of the string is configurable. For a length of 8, some examples outputs are: 'mzSsqUOR', 'YkDXJF0E', 'zv52JbGH', 'czHoBnkJ'.

Installation

Install via pip:

pip install nicknamer

Usage

Below are example usages for the library. The docstrings for the individual classes may have more information.

Random word generation

To use the random word generation:

import nicknamer

# example format string
format_str="<noun>-<verb>-<adjective>"
word_generator = nicknamer.NickNamer(
    seed=12345,
    generator_class=nicknamer.WordNickNamer,
    format_str=format_str,
)
# print 3 example values
print(word_generator.get_value())
print(word_generator.get_value())
print(word_generator.get_value())

This will print:

Immortality-Sightsman-Aculeate
Stratifying-Touser-Vermifugal
Evangelistary-Upholsterer-Inductive

Changing the seed changes the values. The NickNamer class handles the random numbers, but you can also can also do that yourself and use WordNickNamer directly:

import random
import nicknamer

# example format string
format_str="<noun>-<verb>-<adjective>"
word_generator_alt = nicknamer.WordNickNamer(format_str=format_str)

rng = random.Random(12345)

# print 3 example values
print(word_generator_alt.get_value_from_generator(rng))
print(word_generator_alt.get_value_from_generator(rng))
print(word_generator_alt.get_value_from_generator(rng))

This gives the same results. get_value_from_generator() will accept any generator that implements a choice() function to select a value from a list. For example, a numpy random generator will work. Note that numpy must be installed separately.

import numpy
import nicknamer

# example format string
format_str="random verb: <verb>"
word_generator_alt = nicknamer.WordNickNamer(format_str=format_str)

rng = numpy.random.default_rng(12345)

# print example value
print(word_generator_alt.get_value_from_generator(rng))

Random alphanumeric generation

To use the random alphanumeric generation:

import nicknamer

alphanum_generator = nicknamer.NickNamer(
    seed=12345,
    generator_class=nicknamer.AlphaNumNickNamer,
    length=10,
)
# print 3 example values
print(alphanum_generator.get_value())
print(alphanum_generator.get_value())
print(alphanum_generator.get_value())

This will print:

zaZswmJkhA
IkIw7f8zFj
Slvbv78Ua6

This can also be used directly with an external random generator by creating the object nicknamer.AlphaNumNickNamer(length=10) and using get_value_from_generator(rng) as above.

License

apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nicknamer-0.0.1.tar.gz (319.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nicknamer-0.0.1-py3-none-any.whl (317.6 kB view details)

Uploaded Python 3

File details

Details for the file nicknamer-0.0.1.tar.gz.

File metadata

  • Download URL: nicknamer-0.0.1.tar.gz
  • Upload date:
  • Size: 319.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nicknamer-0.0.1.tar.gz
Algorithm Hash digest
SHA256 14c7b5b7200f532549b1e5ada407beba1b05986f4d0f66e09027ba89dabdfb7b
MD5 fa32d3f475c18341094a2b8e0ae490f8
BLAKE2b-256 94dfb7c1f93d1569eb3c05ba4943be9ef9417d4dacea9edbaebe1f9c91f4d7f1

See more details on using hashes here.

File details

Details for the file nicknamer-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: nicknamer-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 317.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for nicknamer-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4d47e2970c297f8d5c11d2e555b1b74bd77206325b5591df2c825ce94b1ca70
MD5 0f8afbe42f240e42b382641cfd65d9f3
BLAKE2b-256 57ddccf6d0a44f60a11e1bb7ebb9afe5a477b15091779aca8f82b5d3607e9c19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page