Mar-10-2022, 09:01 PM
(This post was last modified: Mar-10-2022, 09:08 PM by knackwurstbagel.)
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
And this is the problem. As yourself what is
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.
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 outputf'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 scopeAnd 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?