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.

Usage

Use the Structure class to access (deep) copies of substructures by either a string comprised of the segments of the keys or indexes in the "path" addressing the substructure or value in the nested collection, 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 Structure
>>>
>>> readonly = Structure(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 allows changes to the underlying data structure, 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.3.0.tar.gz (16.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.3.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ncw-0.3.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.10

File hashes

Hashes for ncw-0.3.0.tar.gz
Algorithm Hash digest
SHA256 e9e7c5469ae02446aad65b5a67bcfe9dde7e8988c732f3c29bc468e96bc7a889
MD5 33ba54624ad1637b4f626b4cdc948769
BLAKE2b-256 a8184678c62e1ddb8001ca6c0b7529ab83bb6f5a761825134a717a555afe15c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ncw-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.10

File hashes

Hashes for ncw-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e40043ec7be7a446e282e7a467fa413b2c7a79c386b15457c0ed5bc0f1be866
MD5 a1770fe066367c9afab572628072926c
BLAKE2b-256 cec1231d227daa003e0dd2dd7c356cffa77ca3741e347b6d815134a732a54e79

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