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.6.tar.gz (3.4 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.6-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for persistentobjects-0.1.6.tar.gz
Algorithm Hash digest
SHA256 e02fa7b88ad4c5f670a2db50f988be80c818f1327aa7588a3df2efc64b9d93df
MD5 049c9c496d6b31da4be8023dace5832c
BLAKE2b-256 0d53276b589e5c0836ed525f29d1d7a9d9e669610e2c0fbbc067532cbcc3070a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for persistentobjects-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 03b6bb67e5c81918a9d88903597f98fa4270903fac9f6cca434fa903dae97a86
MD5 d8a483b0217e60c3592692859abadc68
BLAKE2b-256 0fcd83900b8c31dc5fdab528f6abb2ca9632fcd5e95e7d503eb192f64131a776

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