Skip to main content

Another simple ioc framework for python

Project description


GitHub Testing PyPI GitHub code size in bytes

Another simple ioc framework for python.


from anyioc import ServiceProvider
provider = ServiceProvider()
provider.register_singleton('the key', lambda ioc: 102) # ioc will be a `IServiceProvider`
value = provider.get('the key')
assert value == 102

Register and resolve

By default, you can use following methods to register services:

  • ServiceProvider.register_singleton(key, factory)
  • ServiceProvider.register_scoped(key, factory)
  • ServiceProvider.register_transient(key, factory)
  • ServiceProvider.register(key, factory, lifetime)
  • ServiceProvider.register_value(key, value)
  • ServiceProvider.register_group(key, keys)
  • ServiceProvider.register_bind(new_key, target_key)

And use following methods to resolve services:

  • ServiceProvider.__getitem__(key)
  • ServiceProvider.get(key)
  • ServiceProvider.get_many(key)

get return None if the service was not found, but __getitem__ will raise a ServiceNotFoundError.

Read full documentation.

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

anyioc-0.15.0.tar.gz (13.9 kB view hashes)

Uploaded source

Built Distribution

anyioc-0.15.0-py3-none-any.whl (18.5 kB view hashes)

Uploaded py3

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