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 details)

Uploaded Source

Built Distribution

empower-0.2.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file empower-0.2.1.tar.gz.

File metadata

  • Download URL: empower-0.2.1.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.7.12 Darwin/21.3.0

File hashes

Hashes for empower-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c9b16d0bd38c8aadc80db74c50ae5c9069454460f843c091ed25bd0004ec71a1
MD5 4f6db7a8fab9b6916c83c11246d70191
BLAKE2b-256 18b5b7d4baabf40593f6383527ca44e304f6750d07402cf19567f665cfaf27c8

See more details on using hashes here.

File details

Details for the file empower-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: empower-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.14 CPython/3.7.12 Darwin/21.3.0

File hashes

Hashes for empower-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e3f2810e78aec272d888fd0f48dee4ada93398f9a84d5a3fb31ce2b8281aca9
MD5 e7c6d6f3e44aae5f345a86f932c92cd5
BLAKE2b-256 38c45ca23d160eff0ad6ee0e41c1ab41843a6a0965755c9c6b0dbf81523df3ad

See more details on using hashes here.

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