mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 09:36:48 +03:00
19 lines
518 B
Python
19 lines
518 B
Python
"""Dynamic container example."""
|
|
|
|
from dependency_injector import containers, providers
|
|
|
|
|
|
if __name__ == '__main__':
|
|
container = containers.DynamicContainer()
|
|
container.factory1 = providers.Factory(object)
|
|
container.factory2 = providers.Factory(object)
|
|
|
|
object1 = container.factory1()
|
|
object2 = container.factory2()
|
|
|
|
print(container.providers)
|
|
# {
|
|
# 'factory1': <dependency_injector.providers.Factory(...),
|
|
# 'factory2': <dependency_injector.providers.Factory(...),
|
|
# }
|