mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 17:47:02 +03:00
0bb30f91ef
* Update docblocks of factory provider examples * Edit singleton docs
17 lines
326 B
Python
17 lines
326 B
Python
"""`Singleton` provider example."""
|
|
|
|
from dependency_injector import providers
|
|
|
|
|
|
class UserService:
|
|
...
|
|
|
|
|
|
user_service_provider = providers.Singleton(UserService)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
user_service1 = user_service_provider()
|
|
user_service2 = user_service_provider()
|
|
assert user_service1 is user_service2
|