python-dependency-injector/examples/providers/factory.py

20 lines
339 B
Python
Raw Permalink Normal View History

"""`Factory` provider example."""
from dependency_injector import containers, providers
class User:
...
class Container(containers.DeclarativeContainer):
user_factory = providers.Factory(User)
2021-09-30 22:32:21 +03:00
if __name__ == "__main__":
container = Container()
user1 = container.user_factory()
user2 = container.user_factory()