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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ncw-0.4.4.tar.gz
Algorithm Hash digest
SHA256 bd3b24107e18fd056089189ac41d439a1fcb26c237eeef1730b591697f93da88
MD5 424af6d0826dc56a308df9898b5ca586
BLAKE2b-256 260bee3ee5caca854943a599e1983c92a39abbab71c29345a6123649381648cf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ncw-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 271c529424f7eb6df5beb557a0dee601c518e36391f7d701592c89eb545cd81d
MD5 150778f76fd0fe9b8b7eee931b2d046b
BLAKE2b-256 44e841b4977294e359095d654e16606fec6164941f5fa843adadf7102226c36a

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