A simple dependency injector for Python
Project description
dinjector
A simple dependency injector for Python.
Installation
You can install the package using pip:
pip install dinjector
Usage
Here's an example of how to use dinjector:
```python
from dinjector.injector import Injector, inject
class Service:
def __init__(self, config):
self.config = config
class Config:
pass
Injector.register(Service, config=Config())
class Client:
@inject
def __init__(self, service: Service):
self.service = service
client = Client()
print(client.service) # Instance of Service with injected Config
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
dinjectorr-0.1.0.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for dinjectorr-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9756b28d1e189061a893f68609d581a1095e2afd4d61d599df2f50a30ed6225b |
|
MD5 | 1308edc0a50e3f9acd0bebd005f4a37a |
|
BLAKE2b-256 | db8b3a2c22cf704693b7f50c61fbcb922280afe171b0baa868d986e4dc6df286 |