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(post.name for post in self._fetcher.fetch_all())

bindings = zuice.Bindings()
bindings.bind(BlogPostFetcher).to_instance(blog_post_fetcher)

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-pre4.tar.gz (10.0 kB view details)

Uploaded Source

File details

Details for the file zuice-0.3.0-pre4.tar.gz.

File metadata

  • Download URL: zuice-0.3.0-pre4.tar.gz
  • Upload date:
  • Size: 10.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for zuice-0.3.0-pre4.tar.gz
Algorithm Hash digest
SHA256 97a3b5fb4c0d87e1b20f2181a3e284e087858aa7340acf2f880a04bddc9ef6e2
MD5 ff1fb38aa95c457faa2f34ed1ab7c87c
BLAKE2b-256 6560225c085ea2a1a2fbcebd3342a7402b0ee6e9de948ac9534215ca2b557080

See more details on using hashes here.

Supported by

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