Skip to main content

Library to update nested dicts and lists

You can change the values in a flattened version of your dict that NestedNop creates for you. After you editing, NestedNop updates the original structure automatically.

pip install nestednop 
    dictoriginal=data={'level1': {'t1': {'s1': {'col1': 5, 'col2': 4, 'col3': 4, 'col4': 9},

                   's2': {'col1': 1, 'col2': 5, 'col3': 4, 'col4': 8},

                   's3': {'col1': 11, 'col2': 8, 'col3': 2, 'col4': 9},

                   's4': {'col1': 5, 'col2': 4, 'col3': 4, 'col4': 9}},

            't2': {'s1': {'col1': 5, 'col2': 4, 'col3': 4, 'col4': 9},

                   's2': {'col1': 1, 'col2': 5, 'col3': 4, 'col4': 8},

                   's3': {'col1': 11, 'col2': 8, 'col3': 2, 'col4': 9},

                   's4': {'col1': 5, 'col2': 4, 'col3': 4, 'col4': 9}},

            't3': {'s1': {'col1': 1, 'col2': 2, 'col3': 3, 'col4': 4},

                   's2': {'col1': 5, 'col2': 6, 'col3': 7, 'col4': 8},

                   's3': {'col1': 9, 'col2': 10, 'col3': 11, 'col4': 12},

                   's4': {'col1': 13, 'col2': 14, 'col3': 15, 'col4': 16}}},

    'level2': {'t1': {'s1': {'col1': 5, 'col2': 4, 'col3': 9, 'col4': 9},

                   's2': {'col1': 1, 'col2': 5, 'col3': 4, 'col4': 5},

                   's3': {'col1': 11, 'col2': 8, 'col3': 2, 'col4': 13},

                   's4': {'col1': 5, 'col2': 4, 'col3': 4, 'col4': 20}},

            't2': {'s1': {'col1': 5, 'col2': 4, 'col3': 4, 'col4': 9},

                   's2': {'col1': 1, 'col2': 5, 'col3': 4, 'col4': 8},

                   's3': {'col1': 11, 'col2': 8, 'col3': 2, 'col4': 9},

                   's4': {'col1': 5, 'col2': 4, 'col3': 4, 'col4': 9}},

            't3': {'s1': {'col1': 1, 'col2': 2, 'col3': 3, 'col4': 4},

                   's2': {'col1': 5, 'col2': 6, 'col3': 7, 'col4': 8},

                   's3': {'col1': 9, 'col2': 10, 'col3': 11, 'col4': 12},

                   's4': {'col1': 13, 'col2': 14, 'col3': 15, 'col4': 16}}}}



    from nestednop import NestedNop

    nest=NestedNop(dictoriginal)

    for key, item in nest.iterable_flat.items():

        if item['get_value']() == 4 and key[-1] == 'col3':

            item['set_value'](400000000000000)



    updatediter = nest.get_updated_iterable()





    updatediter

    {'level1': {'t1': {'s1': {'col1': 5,

        'col2': 4,

        'col3': 400000000000000,

        'col4': 9},

       's2': {'col1': 1, 'col2': 5, 'col3': 400000000000000, 'col4': 8},

       's3': {'col1': 11, 'col2': 8, 'col3': 2, 'col4': 9},

       's4': {'col1': 5, 'col2': 4, 'col3': 400000000000000, 'col4': 9}},

      't2': {'s1': {'col1': 5, 'col2': 4, 'col3': 400000000000000, 'col4': 9},

       's2': {'col1': 1, 'col2': 5, 'col3': 400000000000000, 'col4': 8},

       's3': {'col1': 11, 'col2': 8, 'col3': 2, 'col4': 9},

       's4': {'col1': 5, 'col2': 4, 'col3': 400000000000000, 'col4': 9}},

      't3': {'s1': {'col1': 1, 'col2': 2, 'col3': 3, 'col4': 4},

       's2': {'col1': 5, 'col2': 6, 'col3': 7, 'col4': 8},

       's3': {'col1': 9, 'col2': 10, 'col3': 11, 'col4': 12},

       's4': {'col1': 13, 'col2': 14, 'col3': 15, 'col4': 16}}},

     'level2': {'t1': {'s1': {'col1': 5, 'col2': 4, 'col3': 9, 'col4': 9},

       's2': {'col1': 1, 'col2': 5, 'col3': 400000000000000, 'col4': 5},

       's3': {'col1': 11, 'col2': 8, 'col3': 2, 'col4': 13},

       's4': {'col1': 5, 'col2': 4, 'col3': 400000000000000, 'col4': 20}},

      't2': {'s1': {'col1': 5, 'col2': 4, 'col3': 400000000000000, 'col4': 9},

       's2': {'col1': 1, 'col2': 5, 'col3': 400000000000000, 'col4': 8},

       's3': {'col1': 11, 'col2': 8, 'col3': 2, 'col4': 9},

       's4': {'col1': 5, 'col2': 4, 'col3': 400000000000000, 'col4': 9}},

      't3': {'s1': {'col1': 1, 'col2': 2, 'col3': 3, 'col4': 4},

       's2': {'col1': 5, 'col2': 6, 'col3': 7, 'col4': 8},

       's3': {'col1': 9, 'col2': 10, 'col3': 11, 'col4': 12},

       's4': {'col1': 13, 'col2': 14, 'col3': 15, 'col4': 16}}}}

Metadata

Release files for nestednop 0.1

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

Source distribution (sdist)

Source distribution for nestednop 0.1
File Size Uploaded Provenance Actions
nestednop-0.1.tar.gz 5.7 kB Without provenance Details for nestednop-0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nestednop 0.1
File Interpreter ABI Platform Actions
nestednop-0.1-py3-none-any.whl Python 3 none any Details for nestednop-0.1-py3-none-any.whl

Total release size: 12.5 kB

Release files / nestednop-0.1.tar.gz

Download URL nestednop-0.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f98b6ec8575898255ed03b80794a03492f100689f3e21051f42d2f16033cea47
BLAKE2b-256 checksum
How to use checksums
df5c8c3505b8a8d11540e47e90a93631357ef6d6e7c1d1b8be0fcaef46317689
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / nestednop-0.1-py3-none-any.whl

Download URL nestednop-0.1-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64183e486ee3ac4bf0350d26a0163986a4a73bb8d65b98ebc6f97c3e753c66a2
BLAKE2b-256 checksum
How to use checksums
0699f98ec0bf31a3593d12878f46ed4fe56bf59beb2b92db4a4608ece398b747
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for nestednop 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

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