Skip to main content

dict-to-object

import dicttoobject

test_dict = {
    "key1": 1,
    "key2": {
        "key3": "value3"
    }
}

readonly_object = dicttoobject.dict_to_readonly_object(test_dict)
print(readonly_object)
# ReadOnlyObject(key1=1, key2=ReadOnlyObject(key3='value3'))

try:
    readonly_object.key2 = 2
except dicttoobject.DoNotWriteError as e:
    print(e.attr_name)
    # key2
    print(e.attr_value)
    # 2

writable_object = dicttoobject.dict_to_writable_object(test_dict)
print(writable_object)
# WritableObject(key1=1, key2=WritableObject(key3='value3'))

writable_object.key2.key3 = 3
print(writable_object.key2.key3)
# 3

writable_object.key4 = 4
print(writable_object.key4)
# 4

dict_from_readonly = dicttoobject.object_to_dict(readonly_object)
print(dict_from_readonly)
# {'key1': 1, 'key2': {'key3': 'value3'}}

dict_from_writable = dicttoobject.object_to_dict(writable_object)
print(dict_from_writable)
# {'key1': 1, 'key2': {'key3': 3}, 'key4': 4}

Release files for dict-to-object 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dict-to-object 1.0.3
File Size Uploaded
dict-to-object-1.0.3.tar.gz 2.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dict-to-object 1.0.3
File Interpreter ABI Platform
dict_to_object-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.1 kB

Release files / dict-to-object-1.0.3.tar.gz

Download URL dict-to-object-1.0.3.tar.gz
Size 2.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a4a75cf10699321662e1db3e117f3dc131b2c8f92360c7ed4abff7769c33d4f0
BLAKE2b-256 checksum
How to use checksums
6b4906a7a5c53bc11c7f6d8cd12e34a1bc66d6d64b1971fbabb74cf1c1333a0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / dict_to_object-1.0.3-py3-none-any.whl

Download URL dict_to_object-1.0.3-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27bb21c70a391c035dd1814e06443f9904545f7dbbd628d642050c7cc8063796
BLAKE2b-256 checksum
How to use checksums
2c12c28013b89066cb333716c8da9b884571ef3a666682ac97790000cabc6c76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

1.0.3 This release

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page