Python Forum
ATM machine (deposits/withdrawals) using OOP
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ATM machine (deposits/withdrawals) using OOP
#9
Trying to be vauge here wile giving you something to look into, I want to help you break down the error

I made two observations, You have defined two classes, one for Account and one for TimeZone, you have tested TimeZone and it appears successful when you instantiate it in the python repl. Good job so far. Now the traceback says
AttributeError: 'Account' object has no attribute 'transaction_time_id_format'
So lets try to understand that. You have already isolated which line we are arguing about. Account object, OK so that's our instance stored in BA . Now lets look at what the computer might be thinking, overly simplified:

print(- I need to print something to output
f'D--.........' -- ok so its a format string
{self.account_num} -- does BA have an account_num property? .. ah yes its there (was declared inside __init__)
{TimeZone(self.transaction_time_id_format)} -- so I need to instantiate a TimeZone with ...
self.transaction_time_id_format -- but BA does not define a transaction_time_id_format that's not in scope

And this is the problem. As yourself what is self what does it refer to. From which object is it going to get transaction_time_id_format from?

I don't want to write code here or answer your question directly but I would suggest reading more about self and scoping. Every object instance gets its own.
Apologetic Canadian, Sorry about that eh?
Reply


Messages In This Thread
RE: ATM machine (deposits/withdrawals) using OOP - by knackwurstbagel - Mar-10-2022, 09:01 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020