Skip to main content

Randomit 🎲

A Python library to generate random things.

codecov coverage example workflow

pypi package badge brought by Gemfury Downloads

pypi package versions brought by shields.io licence brought by shields.io repo size

twitter account brought by shield.io


Currently, randomit can:

To see what's coming next, see open projects.

💡Usage

Words/addresses will always be different on each execution no matter what arguments being passed.

Get Random Words

from randomit.randomizer import Words

# return one word
Words(theme='random words').randomize(return_one_word=True)
# cabinet
# bristlecone pine
# dim - bright

Words(theme='random words').randomize()  # returns a list of 17k words
Words(theme='random words').randomize(amount_to_return=3)  # ['axis', 'overabundant', 'superuser']

Words(theme='random words').randomize(letter_starts_with='A')  # returns all words that starts with letter "A" 
Words(theme='random words').randomize(letter_starts_with='A', amount_to_return=3)  # ['abandoned', 'able', 'absolute']
Words(theme='names').randomize(letter_starts_with='A', amount_to_return=3, capitalize=True)  # ['Apron', 'Ashes', 'Anvil']

Get Random Addresses

import json

address_list = Words(theme='address').randomize(amount_to_return=1, return_dict=True)

print(json.dumps(address_list, indent=2))

'''
[
  {
    "address": "279 troy road",
    "city": "east greenbush",
    "state": "ny",
    "zip": "12061"
  }
]
'''

# if "return_dict" argument isn't specified it will return a list():
'''
["2465 hempstead turnpike, east meadow ny 11554"]
'''

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

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').randomize()  # pass available arguments

Load and pass file(s) with words

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).randomize(capitalize=True, return_one_word=True)

# Bazinga!

Get Random Images

Enter any query, and it will return a random image(s) URL based on the provided query, and it will be random on each execution.

Note: If you don't need this feature and want to get rid of dependencies, use poetry remove package_name

from randomit.randomizer import Images

Images(query='cats', amount_to_return=3).get_randomized() 
# ['https://images.pexels.com/photos/1170986/pexels-photo-1170986.jpeg', 'https://images.pexels.com/photos/1056251/pexels-photo-1056251.jpeg', 'https://images.pexels.com/photos/1056251/pexels-photo-1056251.jpeg']

# if "amount_to_return" argument is not specified -> defaults to batch of 100 images.

📡 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 and VSCode).

📜 Docs

To read more in-depth about something, visit documentation page. Currently, there's nothing there. It's under development. Soon there will be more examples.

Metadata

Release files for randomit 0.2.7

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

Built distribution (wheel)

Table of built distributions (wheels) for randomit 0.2.7
File Interpreter ABI Platform
randomit-0.2.7-py3-none-any.whl Python 3 none any Details

Release files / randomit-0.2.7-py3-none-any.whl

Download URL randomit-0.2.7-py3-none-any.whl
Size 131.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a52d0d500c271cc7f5c43cac5d4789e32a38b2e361d09bfb2881641596a3f00
BLAKE2b-256 checksum
How to use checksums
8b29e6c68e66abe3ea1b369804302b20c9a143a1af2b316d1a2a00a71fec75e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.10 CPython/3.9.5 Windows/10

Release history Release notifications | RSS feed

This release

0.2.7 This release

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

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