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.4.0.tar.gz (22.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.4.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ncw-0.4.0.tar.gz
Algorithm Hash digest
SHA256 6f7b004dfa950addf64835a51e256aee3722535e42f565bdc7c92e0639cdee25
MD5 a63cc9788859f707da83e0518b5ae947
BLAKE2b-256 d2a4a4684d8a8414e4bbff116e5492a96067c36ce60ffe80f8974b08721a49dd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ncw-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4798ed8cdf452925a931c9922bb0e5c934f2cab5b30644d34594af72facf87a
MD5 ca96db78048a31cf3c25ce9fd4569efb
BLAKE2b-256 f540c0a407b35afe439a49125ff7c79b41491cfa6863b2a0fdaf9c5283a1406f

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