Skip to main content

A dependency injection framework for Python

Project description

import zuice

class BlogPostLister(zuice.Base):
    _fetcher = zuice.dependency(BlogPostFetcher)

    def all(self):
        return ", ".join( for post in self._fetcher.fetch_all())

bindings = zuice.Bindings()

injector = zuice.Injector(bindings)
assert injector.get(BlogPostFetcher) is blog_post_fetcher
injector.get(BlogPostLister) # constructs BlogPostLister using the bound instance of BlogPostFetcher

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

zuice-0.3.0.tar.gz (10.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page