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.4.tar.gz (26.0 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.4-py3-none-any.whl (31.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ncw-0.5.4.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.3","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.4.tar.gz
Algorithm Hash digest
SHA256 b8efa0c46bde6d5098b0d50f32151b5a6d436152ae21e0ff7ca0219e3fe85a02
MD5 e72b6583e1d933d8c529d492d235e899
BLAKE2b-256 b96660490adb7fad3a7c1d135dcbd193221b384af60ea072a75a771b8eca0d15

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ncw-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 31.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.3","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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0c37aafc3bf2e017a59c5ab9659c0fee4f70e413540ca185836e0555a47b6ac7
MD5 04b829fad4923916d7c80922cb39beb1
BLAKE2b-256 eacf30d25632a4c4a0135cbc090b74c99ebc9657b81779dfd89acadb50bd9b34

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