Skip to main content

A Python library for generating realistic random names, usernames, and placeholder data for testing purposes.

Project description

randname

A lightweight, dependency-free Python library for generating realistic random names, usernames, and placeholder data for testing purposes.

Python 3.8+ License: MIT PyPI version

โœจ Features

  • ๐ŸŽฏ Zero dependencies - Uses only Python standard library
  • ๐Ÿ“ Realistic names - Curated datasets of real first and last names
  • ๐Ÿ‘ค Gender support - Male, female, unisex, or random name generation
  • ๐ŸŽฎ Username styles - Simple, professional, and gamer-style usernames
  • ๐Ÿ”ค Type hints - Full type annotation support
  • ๐Ÿ“š Well documented - Comprehensive docstrings and examples

๐Ÿ“ฆ Installation

pip install randname

Or install from source:

git clone https://github.com/yourusername/randname.git
cd randname
pip install -e .

๐Ÿš€ Quick Start

import randname

# Generate random names
print(randname.full_name())           # "Sarah Johnson"
print(randname.first_name())          # "Michael"
print(randname.last_name())           # "Williams"

# Generate with specific gender
print(randname.full_name(gender="male"))     # "Robert Brown"
print(randname.full_name(gender="female"))   # "Emily Garcia"
print(randname.full_name(gender="unisex"))   # "Jordan Taylor"

# Generate usernames
print(randname.username())                           # "michael_johnson23"
print(randname.username(style="professional"))       # "m.smith"
print(randname.username(style="gamer"))              # "ShadowHunter99"

# Generate username from a specific name
print(randname.username_from_name("Alice"))                    # "alice_martinez42"
print(randname.username_from_name("Bob", "Wilson"))            # "bobwilson"
print(randname.username_from_name("Jane", style="professional")) # "j.doe"

๐Ÿ“– API Reference

Name Generation

first_name(gender="random")

Generate a random first name.

Parameters:

  • gender (str): One of "male", "female", "unisex", or "random" (default)

Returns: str - A randomly selected first name

randname.first_name()                  # Any gender
randname.first_name(gender="male")     # Male name
randname.first_name(gender="female")   # Female name
randname.first_name(gender="unisex")   # Gender-neutral name

last_name()

Generate a random last name.

Returns: str - A randomly selected last name

randname.last_name()  # "Johnson"

full_name(gender="random")

Generate a random full name (first + last).

Parameters:

  • gender (str): One of "male", "female", "unisex", or "random" (default)

Returns: str - A full name in "FirstName LastName" format

randname.full_name()                   # "Emma Wilson"
randname.full_name(gender="male")      # "James Anderson"

get_available_genders()

Get a list of all available gender options.

Returns: list[str] - ["male", "female", "unisex", "random"]


Username Generation

username(style="simple", add_numbers=True)

Generate a random username.

Parameters:

  • style (str): One of "simple", "professional", or "gamer" (default: "simple")
  • add_numbers (bool): Whether to append random numbers (default: True)

Returns: str - A randomly generated username

randname.username()                                # "johnsmith42"
randname.username(style="simple")                  # "sarah_jones87"
randname.username(style="professional")            # "j.williams"
randname.username(style="gamer")                   # "NightPhoenix99"
randname.username(style="gamer", add_numbers=False)  # "ShadowHunter"

username_from_name(fname, lname=None, style="simple", add_numbers=True)

Generate a username from a provided name.

Parameters:

  • fname (str): First name to base the username on
  • lname (str, optional): Last name (random if not provided)
  • style (str): Username style (default: "simple")
  • add_numbers (bool): Whether to append random numbers (default: True)

Returns: str - A username based on the provided name

randname.username_from_name("Alice")                         # "alicesmith23"
randname.username_from_name("Bob", "Wilson")                 # "bob_wilson"
randname.username_from_name("Jane", style="professional")    # "j.doe"

get_available_styles()

Get a list of all available username styles.

Returns: list[str] - ["simple", "professional", "gamer"]


Utility Functions

random_digits(length=4)

Generate a string of random digits.

randname.random_digits(4)   # "8472"
randname.random_digits(6)   # "123456"

slugify(text, separator="")

Convert a string to a URL/username-safe slug.

randname.slugify("John Doe")              # "johndoe"
randname.slugify("Mary Jane", "_")        # "mary_jane"
randname.slugify("O'Brien")               # "obrien"

capitalize_words(text)

Capitalize the first letter of each word.

randname.capitalize_words("john doe")     # "John Doe"

๐ŸŽจ Username Styles Explained

Style Description Examples
simple Lowercase, basic formats johnsmith, john_doe42, jsmith
professional Clean, work-appropriate john.smith, j.doe, smith.j
gamer Cool prefixes/suffixes ShadowHunter99, NightPhoenix, xDragonx

๐Ÿงช Running Tests

# Run with unittest
python -m pytest tests/ -v

# Or directly
python tests/test_basic.py

๐Ÿ“ Project Structure

randname/
โ”œโ”€โ”€ randname/                 # Main package
โ”‚   โ”œโ”€โ”€ __init__.py          # Public API
โ”‚   โ”œโ”€โ”€ names.py             # Name generation logic
โ”‚   โ”œโ”€โ”€ usernames.py         # Username generation logic
โ”‚   โ””โ”€โ”€ utils.py             # Helper utilities
โ”œโ”€โ”€ tests/                   # Unit tests
โ”‚   โ””โ”€โ”€ test_basic.py
โ”œโ”€โ”€ README.md                # This file
โ”œโ”€โ”€ LICENSE                  # MIT License
โ”œโ”€โ”€ pyproject.toml          # Package configuration
โ””โ”€โ”€ .gitignore

๐Ÿ”ง Development

# Clone the repository
git clone https://github.com/yourusername/randname.git
cd randname

# Install in development mode
pip install -e .

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

๐Ÿ“‹ Extending the Name Dataset

You can easily extend the name datasets by importing and modifying the lists:

from randname.names import MALE_FIRST_NAMES, FEMALE_FIRST_NAMES, LAST_NAMES

# Add custom names
MALE_FIRST_NAMES.extend(["Krishna", "Arjun", "Rahul"])
FEMALE_FIRST_NAMES.extend(["Priya", "Ananya", "Sneha"])
LAST_NAMES.extend(["Patel", "Sharma", "Kumar"])

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Inspired by the need for simple, dependency-free test data generation
  • Name datasets curated from common names across various cultures

Made with โค๏ธ for developers who need quick, realistic test data.

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

randnamepy-1.0.1.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

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

randnamepy-1.0.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file randnamepy-1.0.1.tar.gz.

File metadata

  • Download URL: randnamepy-1.0.1.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for randnamepy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bf693377472a5539e232eab159b21d09fce7050b07a13f7f68605a770d626acb
MD5 916d73ad297643b23b06ad9c44eafbcc
BLAKE2b-256 5702254c2f1650e854f825b159df994d029681000673b2980ecd5eb3dc805104

See more details on using hashes here.

File details

Details for the file randnamepy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: randnamepy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for randnamepy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee129deb28be6d66d55c9841dd976e4e6c5aa724ee303e4bd85ab8f5338121b5
MD5 32d3f795d88373a35019f1d695838b49
BLAKE2b-256 21a36da56775f8b5281c56b13426d212fdda6e4cd4eb0a81c111620c45210361

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