Python library to generate random things.
Project description
Randomit 🎲
A Python library to generate random things.
Currently, randomit
can generate a random word(s) based on a given theme,
as well as load your words files to randomize them.
To see what's coming next, see open projects.
🕹️Usage
Words will always be different on each execution no matter what arguments being passed.
Randomize words
from randomit.words_randomizer import Words
# return one word
Words().randomizer(return_one_word=True)
# cabinet
# bristlecone pine
# dim - bright
Words().randomizer() # returns a list of 17k words
Words().randomizer(words_to_return=3) # ['axis', 'overabundant', 'superuser']
Words().randomizer(letter_starts_with='A') # returns all words that starts with letter "A"
Words().randomizer(letter_starts_with='A', words_to_return=3) # ['abandoned', 'able', 'absolute']
Words().randomizer(letter_starts_with='A', words_to_return=3, capitalize=True) # ['Apron', 'Ashes', 'Anvil']
Get Addresses
If you want to add your list of addresses, have a look at addresses_list.txt
and format it as it's formatted there to work properly.
Format:address, city, state, zip
import json
address_list = Words(theme='address').randomizer(return_dict=True, words_to_return=1)
print(json.dumps(address_list, indent=2))
'''
[
{
"address": "777 brockton avenue",
"city": "abington",
"state": "ma",
"zip": "2351"
}
]
'''
# if "return_dict" argument isn't specified it will return a list():
'''
["2465 hempstead turnpike, east meadow ny 11554"]
'''
Look for available built-in themes
If "theme" argument is not specified ➡ defaults to "random words".
Words().available_themes()
# ['random words', 'names', 'surnames', 'cities', 'countries', 'address']
Specify theme you want to get words from
Words(theme='cities').randomizer() # pass available arguments
Load and pass your file(s)
Make sure all words are lowercase, and start on a new line (\n
), otherwise it won't work.
# call your words
Words(file=YOUR_FILE).randomizer(return_one_word=True, capitalize=True)
# Bazinga!
📡 Installation
$ pip install randomit
$ git clone https://github.com/dimitryzub/randomit.git
👾 Suggestions
If you have any suggestions or ideas what will be good to add, get involved in discussions section.
🔬 Issues
For issues, visit issues page 🙃
Note for replit.com users. If you’re using randomit
on replit, it will throw an error for no obvious for me reason. If you know how to fix it, please, let me know.
Installing package locally via pip
doesn’t produce such error as it should (tested in Pycharm).
📜 Docs
To read more in-depth about something, visit documentation page.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.