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
File details
Details for the file dependencyinjection-0.1.1.0.tar.gz
.
File metadata
- Download URL: dependencyinjection-0.1.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97eb92c0cff5e31b727ec38de40e25c1214a2d5228ab05e899d37cb2d1da4a81 |
|
MD5 | 30608b95b8ef562d5b2262f065474144 |
|
BLAKE2b-256 | e18c8aad562839b2d9afa37905c3502dfbed8ed9443cbf38000eb6e449348779 |
File details
Details for the file dependencyinjection-0.1.1.0-py3.6.egg
.
File metadata
- Download URL: dependencyinjection-0.1.1.0-py3.6.egg
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d91d2de45e7dd03f860dba38d021ecd95a8459bd3aa224fb0a91f96486366f8 |
|
MD5 | 99f55007f95bbde4f04f2cda802acb1b |
|
BLAKE2b-256 | 731530dd97ede2cde65f5078a79f8c865ae70495ebd4df5bf42c0f3017118be5 |