Supports runtime key-path recording/accessing for Python.
Project description
Python Key-path
Supports runtime key-path recording/accessing for Python.
from __future__ import annotations
from runtime_keypath import KeyPath, KeyPathSupporting
class A(KeyPathSupporting):
def __init__(self) -> None:
self.__b = B()
@property
def b(self) -> B:
return self.__b
class B(KeyPathSupporting):
def __init__(self) -> None:
self.__c = C()
@property
def c(self) -> C:
return self.__c
class C:
pass
a = A()
key_path = KeyPath.of(a.b.c)
assert key_path.target is a and key_path.keys == ("b", "c")
assert key_path() is a.b.c
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
runtime-keypath-0.1.3.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for runtime_keypath-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ddd868f7f90049194df1937b78b1043c20d5f39472554b82088775db0af3cfc |
|
MD5 | 03d686c1747ce75cbb7d391ed8a2cca7 |
|
BLAKE2b-256 | ff1b04b4d050f453420271c9e374e668dfcdba1778ad332106d747e2e59c522e |