mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-26 03:23:58 +03:00
22 lines
491 B
Python
22 lines
491 B
Python
"""The Code, that follows Inversion of Control principle."""
|
|
|
|
|
|
class Service(object):
|
|
"""Some "Service"."""
|
|
|
|
|
|
class Client(object):
|
|
"""Some "Client" that uses "Service"."""
|
|
|
|
def __init__(self, service): # Service instance is injected in Client
|
|
"""Initializer."""
|
|
self.service = service
|
|
|
|
|
|
if __name__ == '__main__':
|
|
# Application creates Service instance
|
|
service = Service()
|
|
|
|
# and inject Service instance into the Client
|
|
client = Client(service)
|