Object-oriented paths


Keywords
dict, dictionary, list, lookup, path, pathable
License
Apache-2.0
Install
pip install pathable==0.5.0b2

Documentation

pathable

Package version Continuous Integration Tests coverage Python versions Package format Development status

About

Pathable provides a flexible, object-oriented interface for traversing and manipulating hierarchical data structures (such as lists or dictionaries) using path-like syntax. It enables intuitive navigation, access, and modification of nested resources in Python.

Key features

  • Intuitive path-based navigation for nested data (e.g., lists, dicts)
  • Pluggable accessor layer for custom data sources or backends
  • Pythonic, chainable API for concise and readable code

Usage

from pathable import DictPath

d = {
    "parts": {
        "part1": {
            "name": "Part One",
        },
        "part2": {
            "name": "Part Two",
        },
    },
}

dp = DictPath(d)

# Concatenate paths with /
parts = dp / "parts"

# Stat path keys
"part2" in parts

# Open path dict
with parts.open() as parts_dict:
    print(parts_dict)

Installation

Recommended way (via pip):

pip install pathable

Alternatively you can download the code and install from the repository:

pip install -e git+https://github.com/p1c2u/pathable.git#egg=pathable