JSON-backed attribute-persistent object with namespace support
Project description
This is a very simple lib that provides the PersistantObject class, which saves all its attributes to the given json file. Exceptions are attributes suffixed with '_'. Attributes are saved as soon as they are set.
[!IMPORTANT]
morphing actions like appending, inserting, extending, etc. will not automaticly save! so its recomended to create a temp var, then append to it and at the end set the PersistantObject attr to the temp var.
with namespace(NAME) seperate sub namespaces can be created inside the object.
Usage example:
from PersistantObject import PersistantObject
pobject = PersistantObject("save.json")
pobject.first_value = 10
pobject.second_value = "foo"
namespace = pobject.namespace("test_namespace") # creates a new namespace (new subdict in json)
namespace.third_value = [10, 5]
pobject.temp_ = True # suffixed with '_' so it will not be saved and behaves like a normal attribute.
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.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file persistentobjects-0.1.5.tar.gz.
File metadata
- Download URL: persistentobjects-0.1.5.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bb274721b2d0a4280cf5e85c7518b82a825d087b73f6ad9cfa6eafd290b2fc5
|
|
| MD5 |
69cca88b058663979dd0dc32f51e12de
|
|
| BLAKE2b-256 |
10c1830bd43464491d810c664ebca28c4f1d5800489cdbd76924abfb598db26e
|
File details
Details for the file persistentobjects-0.1.5-py3-none-any.whl.
File metadata
- Download URL: persistentobjects-0.1.5-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5f5e8f9739215dcb97c29ec33d939f1550dfde072e81ad751a085e082b41dfd
|
|
| MD5 |
1e0eedbd05f9aa6a2af0f422cb53ed2a
|
|
| BLAKE2b-256 |
098711df368025bc26ba47002d6dee760652559ee87baaf6197be8bcdc9a43a4
|