python-dependency-injector/examples/di_demo/example_di.py
Roman Mogylatov 6eff213a68
Migrate to alabaster (#264)
* Add bootstrap and remove created at from ghnav-flask app

* Update readme

* Add logo to the docs

* Update key features description

* Update README

* Change headers of API docs

* Add alabaster theme config

* Update docs index

* Add tutorials section

* Update what is DI page

* Update DI in Python page

* Update tutorials index page

* Update provider docs

* Update container docs

* Update examples docs
2020-07-18 00:40:14 -04:00

19 lines
472 B
Python

"""The Code that demonstrates dependency injection pattern."""
class Service:
"""The Service."""
class Client:
"""The Client that uses the Service."""
def __init__(self, service): # The Service is injected into the Client
"""Initialize the Client."""
self.service = service
if __name__ == '__main__':
service = Service() # Application creates the Service
client = Client(service) # and inject the Service into the Client