Transfer function - finding a class by name

Hi,

I am working on the Budget Application and have run into a problem. A transfer of funds is happening between two instances of the same class. It has to be set up so when I call the method I just have to enter the amount and destination of the transfer.

`Preformatted text`def transfer(self, amount, destination):
    if amount<= self.currentbalance:
        self.withdraw(amount)
        description.deposit(amount)`Preformatted text`

The withdrawal is easy, I can just use self.withdraw(), but for the deposit I need to reference another instance of the class. This code comes back with the error AttributeError: ‘str’ object has no attribute ‘deposit’.

I tried description.name.deposit(amount), to try and reference the name of the instance (which is a sting). I saw other posts saying using .name was the solution, but I don’t understand how to make it work.

Any help would be really appreciated.

destination is the other class instance here, however it seems that in method that variable is mistaken with another one.

I think I had just confused myself. I though the test required you to convert a string term into the class instance name. I was just making life hard for myself.

Thanks a lot for the reply.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.