mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-23 10:03:56 +03:00
19 lines
491 B
Python
19 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 into Client
|
|
"""Initializer."""
|
|
self.service = service
|
|
|
|
|
|
if __name__ == '__main__':
|
|
service = Service() # Application creates Service instance
|
|
client = Client(service) # and inject Service instance into the Client
|