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.0.tar.gz (17.3 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.0-py3-none-any.whl (22.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ncw-0.5.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"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.0.tar.gz
Algorithm Hash digest
SHA256 0321c01117d67225f3915ed6b745d66455261e83918fcf7c6571ace2176fd6f0
MD5 3e62d371fcb6f44b696605987b70659c
BLAKE2b-256 912864126d9f41567ceea1ae852e3810efdffd0e243f024c94d89f4d51963718

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ncw-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 22.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0b5077f6f36cfc89af03b701c3933aab269819ebcd69ada7066696b6e9159d3
MD5 15fe07c77785be7ea8775bf0a3afdb42
BLAKE2b-256 558631e6ba03869b845bb784dda66ad23d5ffc2af3c208ac953680d70644a327

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