Feb-08-2019, 09:20 AM
We have class:
Can you help me?
class DbConnection: def __init__(self, host: str, port: int, db_name: str): self.__host = host self.__port = port self.__db_name = db_name def get_host(self) -> str: return self.__host def get_port(self) -> int: return self.__port def get_db_name(self) -> str: return self.__db_name class DBCommunicator: def __init__(self, db_connection: DbConnection): self.__db_connection = db_connection def get_connection(self) -> DbConnection: return self.__db_connectionIs a way to create instance like:
arguments = [ db_connection: DbConnection() ] object_instance = DBCommunicator(arguments)In __init__ method I need bound arguments with typehints as in my class code. But I want to have possibility to create instance with different arguments. Like autobound.
Can you help me?