Skip to main content

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]


print(pobject.test_namespace.third_value) # alternate way to access namespaces

pobject.temp_ = True # suffixed with '_' so it will not be saved and behaves like a normal attribute.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

persistentobjects-0.1.7.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

persistentobjects-0.1.7-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file persistentobjects-0.1.7.tar.gz.

File metadata

  • Download URL: persistentobjects-0.1.7.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for persistentobjects-0.1.7.tar.gz
Algorithm Hash digest
SHA256 b054a2309e4ac8be30644a6c3fd8c5d3c8af2beaa3b2716c9754ad811de8c46f
MD5 0383de6af5c9ea34610279ff6b194397
BLAKE2b-256 cd4bed4aed8f29bf542dbef0211e041a315b03c731df4556ac7c7652aeadadfc

See more details on using hashes here.

File details

Details for the file persistentobjects-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for persistentobjects-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 41caadd9eca0395a77e74396c95d8513da08ddee2e2947fa4d1fd0b0abec817f
MD5 ed942769d6a472f4a4c4a1c24436b4ac
BLAKE2b-256 978a8b2a7b8e92447c9875709d23531f9f282f7116e181ca061f0ef8b9adc04a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page