Skip to main content

shufflejar

A jar of choices that remembers what you already picked. Use it for lunch spots, practice prompts, or household chores. Zero runtime dependencies. Python 3.10+. MIT licensed.

Install and run

python -m pip install shufflejar
shufflejar create lunch ramen tacos pizza
shufflejar draw lunch
shufflejar draw lunch
shufflejar undo lunch
shufflejar list

State is saved to .shufflejar.json in the current directory by default. Choose one consistent explicit file to share the same jars across directories:

shufflejar --state choices.json create chores dishes laundry vacuum
shufflejar --state choices.json draw chores

Global flags, including --state, go before the subcommand. Local installation: python -m pip install .. All commands work as python -m shufflejar too.

Python

import random
from shufflejar import ShuffleBag, JarStore

bag = ShuffleBag(["ramen", "tacos", "pizza"], rng=random.Random(42))
picked = bag.draw()
assert bag.undo() == picked

store = JarStore("choices.json")
store.create("practice", ["lists", "loops", "functions"])
choice = store.draw("practice")
assert JarStore("choices.json").undo("practice") == choice

Each item appears once per cycle. After a cycle completes, a new shuffled cycle starts. For bags of two or more items, the first item of a new cycle cannot be the last item of the previous cycle. A one-item bag repeats that item. Items are trimmed, non-empty and unique, with case-sensitive comparisons. Drawing never edits the original choice list.

State and undo

Only the latest draw in each jar can be undone. Undo restores the remaining items and the previous choice. If a cycle had just started, undo returns to the cycle boundary; drawing again can produce a different shuffle.

ShuffleBag.to_dict() and ShuffleBag.from_dict() round-trip validated JSON data, including undo state. They do not persist the random generator state. items returns all choices; remaining shows the rest of the current cycle. An empty remaining list means a new cycle will start on the next draw.

JarStore.create, draw, and undo save atomically after acquiring an exclusive sibling .lock file. Concurrent writers fail rather than overwrite one another. Invalid JSON is reported without resetting your file. If a crash leaves a lock file, ensure no shufflejar process is using the store before removing that specific .lock file manually. Use local storage; remote filesystems may have different locking and atomic-replacement guarantees.

Existing jars cannot be replaced by create. Keep a backup of your JSON file if you edit it manually. This utility uses ordinary pseudorandomness and is not intended for security-sensitive selection.

Exit status: 0 on success, 2 on input/storage errors.

Development

python -m pip install -e .
python -m unittest discover -s tests -v

Metadata

Release files for shufflejar 0.1.0

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

Source distribution (sdist)

Source distribution for shufflejar 0.1.0
File Size Uploaded
shufflejar-0.1.0.tar.gz 6.9 kB Details

Built distribution (wheel)

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

Total release size: 14.1 kB

Release files / shufflejar-0.1.0.tar.gz

Download URL shufflejar-0.1.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b4498ee5aa96cbc58973795a0196887e34e3524d3475b1fec5690147c8a5daa0
BLAKE2b-256 checksum
How to use checksums
d518c3f7f1b19943b72d3ee5566cea395c951475cecf532515d4793dab2d77ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / shufflejar-0.1.0-py3-none-any.whl

Download URL shufflejar-0.1.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
349f6bdeacc841ff511e99089226700d31c2ea17dcd5e5d53e198d6570321e14
BLAKE2b-256 checksum
How to use checksums
ad98ffb80ddfda65e81f05da6195a9e9bd18a85470da9cd0f20a871a7acae487
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

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