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
Release history Release notifications | RSS feed
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.2.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for runtime_keypath-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efcb7c226ec6f8e8482dd079a8ff6e3de2b1e19233e75a79d7c550aeb0eac6ea |
|
MD5 | ec2b7587c837b0b1375b8b16925ab396 |
|
BLAKE2b-256 | 639e6328af3316f676ca50a637587689c983e0bb4ad396e6b40dfaef3adb6293 |