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]

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.4.tar.gz (3.2 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.4-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: persistentobjects-0.1.4.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

Hashes for persistentobjects-0.1.4.tar.gz
Algorithm Hash digest
SHA256 f2d86c86338c8dd67b2d086f7b656217372adf2e91e580f07fd4e1ea0d342ba4
MD5 09d19897e8f08ea7cfd98d9c997fcdeb
BLAKE2b-256 073961d0b05f13a9df445c6c2d2d76d08777bc47f4cedf1ac954e4c921143cad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for persistentobjects-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d1e0e15e6c3e558a0f44df406592880f926a3eaae1810ee8e882fd29fae7df46
MD5 8c084b55a88f7b3b5b992ad3fd30ec86
BLAKE2b-256 6cdd2530a8a3c8de84acd771dee5413015efac7f43943d7f37982e4e090b74ad

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