Quick Start
Basic Usage
Getting started with Randum is simple:
from randum import Randum
# Initialize Randum
rand = Randum()
# Generate fake data
print(rand.name()) # 'John Doe'
print(rand.email()) # 'john.doe@example.com'
print(rand.phone_number()) # '(555) 123-4567'
Using Locales
Randum supports multiple locales for generating localized data:
from randum import Randum
# French locale
rand_fr = Randum('fr_FR')
print(rand_fr.name()) # 'Jean Dupont'
# Spanish locale
rand_es = Randum('es_ES')
print(rand_es.name()) # 'María García'
# Multiple locales
rand_multi = Randum(['en_US', 'fr_FR', 'es_ES'])
print(rand_multi.name()) # Randomly picks from any locale
Seeding for Reproducibility
Set a seed to generate reproducible results:
from randum import Randum
# Set seed for reproducible results
Randum.seed(12345)
rand = Randum()
print(rand.name()) # Always generates the same name
# Reset seed
Randum.seed(12345)
rand2 = Randum()
print(rand2.name()) # Same as above
Unique Values
Generate unique values to avoid duplicates:
from randum import Randum
rand = Randum()
# Generate unique emails
for _ in range(5):
print(rand.unique.email())
# Clear unique cache
rand.unique.clear()
Optional Values
Generate values with a probability of being None:
from randum import Randum
rand = Randum()
# 50% chance of returning None
print(rand.optional.name())
# 80% chance of returning a value
print(rand.optional.email(prob=0.8))