Skip to main content

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))
```

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

dependencyinjection-0.1.2.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

dependencyinjection-0.1.2.0-py3.6.egg (29.0 kB view details)

Uploaded Source

File details

Details for the file dependencyinjection-0.1.2.0.tar.gz.

File metadata

File hashes

Hashes for dependencyinjection-0.1.2.0.tar.gz
Algorithm Hash digest
SHA256 e3e900b34cf3d1544a016da5af8a50f86815eab95f6a4afec3ba38fefca1e6e1
MD5 729f795a10d075ca7d6c5f24915c6148
BLAKE2b-256 439864c4cbecc88634a6be003dd6a8dd27cac1bcf7169c4e2c55d117910df4b3

See more details on using hashes here.

File details

Details for the file dependencyinjection-0.1.2.0-py3.6.egg.

File metadata

File hashes

Hashes for dependencyinjection-0.1.2.0-py3.6.egg
Algorithm Hash digest
SHA256 ac03e2979d01df0ace7b27197bcb00b84ce83a0e6d8e29a13047f225eaffd354
MD5 9b3a7ae282c4b9136ef27913a7558762
BLAKE2b-256 ec657d5798ec57096e8adc7d5cccf52a358096cf6a124cd6993df9812f0931bc

See more details on using hashes here.

Supported by

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