Version: 1.1.0
simple_storage is a lightweight Python module that allows you to
save and load data easily without dealing with file handling or JSON directly.
It is designed to be beginner-friendly and safe, using human-readable JSON files.
Simply place simple_storage.py in the same folder as your Python script
and import it:
from simple_storage import save, load, exists, delete
save("settings", {"theme": "dark", "volume": 70})
This creates a file storage/settings.json with JSON content:
{
"theme": "dark",
"volume": 70
}
settings = load("settings")
print(settings)
If the file does not exist, it returns None by default. You can also provide a default:
settings = load("settings", default={})
if exists("settings"):
print("Settings file found")
delete("settings")
This removes the saved file from the storage folder.
You can store any JSON-safe Python types:
dictliststrintfloatboolNoneUnsupported types include functions, classes, Tkinter widgets, and custom objects.
Each saved item becomes one JSON file in a folder called storage.
The module uses json.dump to convert Python objects to text and
json.load to read them back. The file paths are generated automatically:
storage/your_item_name.json
Example:
save("user_data", {"name": "Andrew", "score": 100})
This creates storage/user_data.json:
{
"name": "Andrew",
"score": 100
}
The module includes a built-in self-test. Run the module directly to test all main features:
python simple_storage.py
Output example:
Running simple_storage tests...
All tests passed successfully.
Current version: 1.1.0
- Patch updates: 1.1.1, 1.1.2 etc. for small fixes
- Minor updates: 1.2.0 for added features
- Major updates: 2.0.0 for breaking changes
from Tkinter_helper import Tkinter_helper
from simple_storage import save, load
gui = Tkinter_helper("Example", 400, 200)
_, name_var = gui.entry("name", default_text=load("name", ""))
def save_name():
save("name", name_var.get())
gui.button("save", text="Save", action=save_name)
gui.root.mainloop()
This shows how user input can be saved and loaded seamlessly using simple_storage.
Free to use for learning and personal projects.