patching nested objects in python

A better design would be to pass the necessary clients as arguments, rather than make each class responsible for knowing how to instantiate such a client.

import os

class PasswordClient:
    def __init__(self, value):
        self.password_db = value

class DBClient:
    def __init__(self, pc):
        self.password_client = pc

class TableQuery:
    def __init__(self, dbc):
        self.db_client = dbc

    def add_person(self):

a = TableQuery(DBClient(PasswordClient(...)))

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top