mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-12-04 23:44:05 +03:00
20 lines
339 B
Python
20 lines
339 B
Python
"""`Factory` provider example."""
|
|
|
|
from dependency_injector import containers, providers
|
|
|
|
|
|
class User:
|
|
...
|
|
|
|
|
|
class Container(containers.DeclarativeContainer):
|
|
|
|
user_factory = providers.Factory(User)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
container = Container()
|
|
|
|
user1 = container.user_factory()
|
|
user2 = container.user_factory()
|