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.0.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

dependencyinjection-0.1.0.2-py3.6.egg (25.0 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for dependencyinjection-0.1.0.2.tar.gz
Algorithm Hash digest
SHA256 d3a0a46360714cda500008708fec55de3ce5051704f74e4774a06595503dcb7a
MD5 f3032a4d24986d46a515b044d8b111b0
BLAKE2b-256 7ffb929b75685a421917b7359daa3cec85e681b052ea1b082a1f32d4ee72f242

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dependencyinjection-0.1.0.2-py3.6.egg
Algorithm Hash digest
SHA256 38d5e6f7ada1327c2d952e4768476a1f4f1cd4ace4416e19f7c54475d8ff7883
MD5 1b85fb88264fa4b35b7b73af41527fc9
BLAKE2b-256 16fef51a2482730a558a615ed2403f79d1cac2319283aa0e9c6ecfe108b9284e

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