Skip to main content

Recursive Namespace. An extension of SimpleNamespace. Enhance get/set and parse from JSON

Project description

RecursiveNamespaceV2

CI Type Check codecov Python Version PyPI version License Code style: ruff

Description

RecursiveNamespaceV2 extends Python's SimpleNamespace to make nested dicts easy to work with using attribute access, dict access, and chain-keys.

Full documentation: https://recursivenamespacev2.readthedocs.io/

Key features:

  • Recursive conversion of nested dicts/lists
  • Attribute and dict access (rn.a and rn["a"])
  • Chain-key access (rn.val_get("a.b.c"))
  • Array indexing and append syntax (items[].0, items[].#)
  • Typed, zero-dependency, pure Python

Installation

pip install RecursiveNamespaceV2

Or with uv:

uv add RecursiveNamespaceV2

For development from source:

git clone https://github.com/pasxd245/RecursiveNamespaceV2.git
cd RecursiveNamespaceV2
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
uv pip install -e ".[test]"

Quick Start

from recursivenamespace import RNS  # or RecursiveNamespace

data = {
    'name': 'John',
    'age': 30,
    'address': {
        'street': '123 Main St',
        'city': 'Anytown'
    },
    'friends': ['Jane', 'Tom']
}

rn = RNS(data)
print(rn.address.city)  # Anytown
print(rn["friends"][1])  # Tom

# Chain-key access
rn.val_set("address.zip", "12345")
print(rn.val_get("address.zip"))  # 12345

# Convert back to dict
data2 = rn.to_dict()
print(data2["address"]["city"])  # Anytown

Examples

See the examples/ directory for 15 runnable examples organized by difficulty (basic, intermediate, advanced, real-world).

Testing

To run tests, navigate to the project's root directory and execute:

uv run pytest -s
# or with coverage:
uv run coverage run -m pytest
# to generate html report:
uv run coverage html

Release

Versions are derived automatically from git tags (via hatch-vcs):

git tag -a v1.2.3 -m "v1.2.3"
git push --tags

CI automatically builds, publishes to PyPI (OIDC trusted publishing), and creates a GitHub Release with auto-generated notes.

Contributing

Contributions to the RecursiveNamespace project are welcome! Please ensure that any pull requests include tests covering new features or fixes. See CONTRIBUTING.md for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Transparency

AI-assisted development (e.g., Claude Code, Copilot) was used for scaffolding and iteration.

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

recursivenamespacev2-0.0.3.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

recursivenamespacev2-0.0.3-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file recursivenamespacev2-0.0.3.tar.gz.

File metadata

  • Download URL: recursivenamespacev2-0.0.3.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for recursivenamespacev2-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c60c2d6bccef1b8dd4cd584bcda28704df85255a297c3b526173c3765790dd7f
MD5 717a2c86f18620c714ebe2caac1f0ce3
BLAKE2b-256 b49b4c21d05c4ac1007b51a99dc9790f257f81aae9cfd87c6350949895869cdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for recursivenamespacev2-0.0.3.tar.gz:

Publisher: publish.yml on pasxd245/RecursiveNamespaceV2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file recursivenamespacev2-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for recursivenamespacev2-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4252793e54c1e2843779d62944e22d862037607b8241e4e21fb3f8e1dad57d29
MD5 99e6ca84ab82eb480824c46e4b8ec026
BLAKE2b-256 f8bd8afca9eda644a2fab2f37f15043cc77c658ace4953b6887b34a7e5e4b4ac

See more details on using hashes here.

Provenance

The following attestation bundles were made for recursivenamespacev2-0.0.3-py3-none-any.whl:

Publisher: publish.yml on pasxd245/RecursiveNamespaceV2

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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