Skip to main content

Nested collections wrapper

Project description

ncw

Nested collections wrapper

Classes to access and/or modify data in nested collections (dict or list instances) of str, int, float, bool, or None, through a Mapping or MutableMapping interface using direct addressing.

Usage

Use the FrozenStructure class to access data in nested collections by either a string comprised of the segments of the keys or indexes in the "path" addressing the substructure or value, joined together by a separator character (usually an ASCII dot: .), or a tuple of these path segments.

>>> serialized = '{"herbs": {"common": ["basil", "oregano", "parsley", "thyme"], "disputed": ["anise", \
"coriander"]}}'
>>>
>>> import json
>>> original_data = json.loads(serialized)
>>>
>>> from ncw import FrozenStructure
>>> readonly = FrozenStructure.from_native(original_data)
>>>
>>> readonly["herbs"]
{'common': ['basil', 'oregano', 'parsley', 'thyme'], 'disputed': ['anise', 'coriander']}
>>> readonly["herbs.common"]
['basil', 'oregano', 'parsley', 'thyme']
>>> readonly["herbs", "common"]
['basil', 'oregano', 'parsley', 'thyme']
>>> readonly["herbs.common.1"]
'oregano'
>>> readonly["herbs", "common", 1]
'oregano'

The MutableStructure class additionally allows changes to the stored data, see the documentation for more details.


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

ncw-0.5.2.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

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

ncw-0.5.2-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file ncw-0.5.2.tar.gz.

File metadata

  • Download URL: ncw-0.5.2.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.22.2","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ncw-0.5.2.tar.gz
Algorithm Hash digest
SHA256 344a89275a442f034f84f86f352a149aaca83b5f1788f37ea6048e97cc843b3d
MD5 1e856f993a1ed609c04c074db54e0b29
BLAKE2b-256 6f0138c4c884b06c873e831aa17e767fdccd7cfcc93d2391628cbc0ae4ff61c3

See more details on using hashes here.

File details

Details for the file ncw-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: ncw-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.15 {"installer":{"name":"uv","version":"0.9.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.22.2","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for ncw-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b12797ec3bb75d69226e43c4f41188d8afc752dc257dbc0fe8b6b12615054502
MD5 279fb5ebe8703824d2baf50b5e274a6d
BLAKE2b-256 5f9352c420515513104cbf6db8954d1daaef15a4c5544f271ea8e0eded1b2c2c

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