Skip to main content

Lo4container

The simplest IoC in python

Install

pip install lo4container

Usage

Creating a container is matter of creating a Container instance

from lo4container import Container
container = Container()

Assign value

We can use container as a dictionary, it means you can assign/get value by key, check existing, ...

container['name'] = 'lo4container'
print(container['name'])
# output: 'lo4container'

'name' in container
# return True

If we use lambda function for value, it would execute with container as argument

import datetime
container['timer'] = lambda c: return datetime.datetime.now()

print(container['time'])
# output: 2018-07-07 14:05:59.941780

Each time you get a value by key, lo4container returns a differences instance. If you want the same instance to be returned for all calls, use share method

import datetime
container['timer'] = lambda c: return datetime.datetime.now()
container.share('timer')

print(container['time'])
# output: 2018-07-07 14:05:59.941780

print(container['time'])
# output: 2018-07-07 14:05:59.941780

print(container['time'])
# output: 2018-07-07 14:05:59.941780
# same results for n calls

Release files for lo4container 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lo4container 0.1.6
File Size Uploaded
lo4container-0.1.6.tar.gz 1.7 kB Details

Release files / lo4container-0.1.6.tar.gz

Download URL lo4container-0.1.6.tar.gz
Size 1.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a07b84227417a01a28e7d6537618ecaa73ff625801706f0ae30a45ac7487123f
BLAKE2b-256 checksum
How to use checksums
24d0e322cb9f5ef6ef5ccf9be041a4fe9c5e3ada6a7519c85f503b1c5bde7cd0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.6 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page