Skip to main content

No project description provided

Project description

Parent Aware

Build Status

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


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)

Uploaded Source

Built Distribution

parent_aware-0.0.1-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page