oop issue

Tola Oj ojomooluwatolami675 at gmail.com
Mon May 23 15:36:12 EDT 2022


i am trying to print this code but it keeps giving me this typeerror,
please help. the csv file format i am trying to change into a list is in a
different module.

class invest_crypto:
    crypto_current_rate = 0.05
    client_list = []
    def __init__(self, name, surname, amount_Deposited, amount_to_transfer):
        self.name = name
        self.surname = surname
        self.amount_Deposited = amount_Deposited
        self.amount_to_transfer = amount_to_transfer

        invest_crypto.client_list.append(self)

    def calculate_customer_transfer(self):
        self.customer_transfer = (self.crypto_current_rate * self.
amount_Deposited) + self.amount_Deposited
        return self.customer_transfer

    @classmethod
    def access_client_details(cls):
        with open('C:\\Users\\ojomo\\OneDrive\\Desktop\\myexcel\\
oop_learn.py\\myExperiment.py\\clientDetails.csv', 'r' ) as f:
            reader = csv.DictReader(f)
            clientDetails = list(reader)

            for item in clientDetails:
                invest_crypto(
                    name=item.get('name'),
                    surname=item.get('surname'),
                    amount_Deposited=item.get('amount_deposited'),
                    amount_to_transfer=item.get('amount_to_transfer')
            )
    @staticmethod
    def __repr__(self):
        return f"('{self.name}', '{self.surname}', '{self.amount_Deposited}',
'{self.amount_to_transfer}')"


invest_crypto.access_client_details()
print(invest_crypto.client_list())


More information about the Python-list mailing list