No project description provided
Project description
# dependency injection
A dependency injection framework for python.
Just like `Microsoft.Extensions.DependencyInjection`.
## Usage
``` py
class A:
pass
class B:
def __init__(self, a: A):
assert isinstance(a, A)
import dependencyinjection as di
service = di.Services()
service.scoped(A)
service.singleton(B)
provider = service.build()
assert isinstance(provider.get(A), A)
assert isinstance(provider.get(B), B)
with provider.scope() as scoped_provider:
assert provider.get(A) is provider.get(A)
assert scoped_provider.get(B) is scoped_provider.get(B)
assert provider.get(B) is scoped_provider.get(B)
assert not (provider.get(A) is scoped_provider.get(A))
```
A dependency injection framework for python.
Just like `Microsoft.Extensions.DependencyInjection`.
## Usage
``` py
class A:
pass
class B:
def __init__(self, a: A):
assert isinstance(a, A)
import dependencyinjection as di
service = di.Services()
service.scoped(A)
service.singleton(B)
provider = service.build()
assert isinstance(provider.get(A), A)
assert isinstance(provider.get(B), B)
with provider.scope() as scoped_provider:
assert provider.get(A) is provider.get(A)
assert scoped_provider.get(B) is scoped_provider.get(B)
assert provider.get(B) is scoped_provider.get(B)
assert not (provider.get(A) is scoped_provider.get(A))
```
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
Built Distribution
Close
Hashes for dependencyinjection-0.1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6927d85257182a6d6334162eb3ceecd360a7bb71bbcd05220b1d50429c583908 |
|
MD5 | 01f3d6f55acc0fe319017ca72aa46ebf |
|
BLAKE2b-256 | 15a88549b0af43ed3de4c696fcc51070a190ccb3d32d5e712f688661d2be9b48 |
Close
Hashes for dependencyinjection-0.1.0.0-py3.6.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6509ba455e7ba4b7542782667eb1fa429a6957e487923686e0279e57b20efa78 |
|
MD5 | 6b5c25c4333930bdfa04a8745d9e78a2 |
|
BLAKE2b-256 | 03c02419e4e5ecb24245f9ada91524344ad1ad40b2b56df62348615e7189687c |