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.1.tar.gz (17.6 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.1-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ncw-0.5.1.tar.gz
  • Upload date:
  • Size: 17.6 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.1.tar.gz
Algorithm Hash digest
SHA256 09c48314f3b7cd17dcf7377e12f8ec5494d93b46eb4cedf9c6dc133c643843be
MD5 61a3904fca4f4b2d50c6e9e4e5dfd212
BLAKE2b-256 f880e0ab08f930448c4be383597eb5dfea23f431e7c747a48011d9182106a7fd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ncw-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 22.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 07acb8bf8db91c6848025dd6736452746fc31d880a13f0ca2edc616f7bde8f38
MD5 091628ba348933a3c9b4fc5ec57733ab
BLAKE2b-256 10ca539cc71ed8120b7d7226eada7b51934fcc8d3d9d917139d13682954e7804

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