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
#11
self is completely a convention, but conventions are important. When calling a method of an instance, Python passes the instance as the first argument. When calling a method of a class, Python passes the class as the first argument. It is convention to use "self" and "cls" for these first arguments. You could use "this" and "class_", but that would confuse others used to the conventions.

Your error is that self is an instance of Account, not an instance of TimeZone. self is an instance of Account because "deposit()" is an instance method of Account, and the first argument in deposit(self) is an instance of Account. Account does not have an attribute "transaction_time_id_format".

Question is, what should have a timezone? Right now I don't think you have any time zones. You have a class, but did you create any instances? And if you have an instance of Timezone, where is that kept? What is a time zone associated with? The Account? I don't know. I can do banking in different time zones. Is the purpose of TimeZone to convert from UTC to my local time, or is it to convert the time from where the transaction took place to UTC?
Reply


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

Forum Jump:

User Panel Messages

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