Skip to main content

Goodbye Inheritance

Project description

empower

Goodbye Inheritance!!!

Install

pip install empower

Usage

You have a Duck class without any methods.

# mod/__init__.py

class Duck:
    ...

You define a trait Fly for Duck

# mod/fly.py

from empower import impl, Trait

from . import Duck

@impl(Duck)
class Fly(Trait):
    def fly(self):
        return "fly"

And you define another trait Run for Duck

# mod/run.py

from empower import impl, Trait

from . import Duck


@impl(Duck)
class Run(Trait):
    def run(self):
        return "run"

Now you can add empower Duck

# main.py

from mod import Duck
from empower import use

duck = Duck()

use("mod.fly")  # load fly trait
use("mod.run")  # load run trait

assert duck.fly() == "fly"
assert duck.run() == "run"

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

empower-0.2.1.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

empower-0.2.1-py3-none-any.whl (7.3 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