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.3.tar.gz (17.9 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.3-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ncw-0.5.3.tar.gz
  • Upload date:
  • Size: 17.9 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.3.tar.gz
Algorithm Hash digest
SHA256 754ef26e778f14df4a622a2ff9ee43e8da37ac5fa497f98db2e018f5e3b27a6f
MD5 a577beabe150b2988eea93467095f755
BLAKE2b-256 58f3754d48835658390eac3f7d52e4d3586b75e489d05b92ca3b23e95c09f412

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ncw-0.5.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f806728ff1e35368ab3fa8bf2cc5d265b15501c470bf36ecb751115fa56c5d17
MD5 605cb83d82d2659aecc19026860e2134
BLAKE2b-256 aed57b90bfcf522e04310898c81e0713dc8bedd3cd1917fdb52cc4e62979a4d5

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