No project description provided
Project description
Parent Aware
A decorator to make objects aware of their parent objects. Particularly useful with dataclasses!
Example
import dataclasses
from parent_aware import parent_aware
@parent_aware
@dataclasses.dataclass
class Child:
num: int
@parent_aware
@dataclasses.dataclass
class Parent:
child: Child
c = Child(2)
p = Parent(child=c)
# Automatically a .parents was added on the child!
assert c.parents == [p]
# If you didn't want .parents, use @parent_aware(parents_name='give_a_name_here')
Installation
pip install parent_aware
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
parent_aware-0.0.1.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for parent_aware-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b7263be816ec10deed2bb46f9e9ed4a898a7e54270715ae7cfd349bc14f670d |
|
MD5 | 77f4740a078e2b14ac61122a30ab3290 |
|
BLAKE2b-256 | d8b96f79ed56d6766988f5fd91090b80351b88c690e0835a2145046db0d46fa3 |