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
Release history Release notifications | RSS feed
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.2.5.tar.gz
(11.4 kB
view details)
File details
Details for the file zuice-0.2.5.tar.gz.
File metadata
- Download URL: zuice-0.2.5.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
251154d7e5f2f9a3bded787c4d28fa7c55b08d871dec9cf0204a3b2a5bade4ec
|
|
| MD5 |
c6b4c6fb401835837dd22b22afbd06ae
|
|
| BLAKE2b-256 |
2a28cbe02596b06210b7b29f304d01985ae489d3d010963c0955ffefc451cf12
|