No project description provided
Project description
anyioc
Another simple ioc framework for python.
Usage
from anyioc import ServiceProvider
provider = ServiceProvider()
provider.register_singleton('the key', lambda x: 102) # x will be scoped ServiceProvider
value = provider.get('the key')
assert value == 102
Need global ServiceProvider ? try from anyioc.g import ioc
.
Details
Predefined keys
There are some predefined keys you can use direct, but you still can overwrite it:
ioc
- get current scoped ServiceProvider instance.provider
- alias ofioc
service_provider
- alias ofioc
provider.get()
vs provider[]
provider[]
will raise ServiceNotFoundError
when service was not found;
provider.get()
only return None
without error.
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
anyioc-0.5.0.tar.gz
(5.6 kB
view hashes)
Built Distribution
anyioc-0.5.0-py3-none-any.whl
(9.4 kB
view hashes)