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.6.tar.gz (8.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.6-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ncw-0.4.6.tar.gz
Algorithm Hash digest
SHA256 28c6faabd342ba7ef17b3c68ed0cec6a2c56b79780087b6b2643c6197492805c
MD5 2b3d474d6878fb2e93255d981e4f2e27
BLAKE2b-256 1b76a21416c8e8a1639e9999fadf0bf56fcf58c070e7cece63ee43d45c300b9c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ncw-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 89bad5de71ec1a5fcab1629bfb2ea3757cf8f1349b14a1deea287d2a72e924f0
MD5 d8f68f8f0efa67e8c2987c5b4370582b
BLAKE2b-256 a012f3d0acd408ac726e932bd7cc5913523241674cfb419ee1b6f39ea82e8a10

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