Jump to content
Chap 7 Pg 224
1 reply to this topic
Posted 24 July 2013 - 12:02 AM
I have started with programing and first time learning OOPS.
My question is with regards to the code shown on page 224.
with this line the first file is taken and run against the function get_coach_data, which in turns call the AthleteList class and should return like below, considering sarah.txt file
ath=Athlete('Sarah Sweeney' , '2002-6-17' , ['2:58' , '2.58' , '1.56'])
My understanding is there will object created call ath with name attribute as Sarah. Is my understanding correct here?
Now when we have put this data into all_athletes dict file, the code given is all_athletes[ath.name]=ath
Shouldn't this be like below
Because the times attribute will have all the timing information of the athlete in question.
Let me know if I am missing something here and excuse if its dumb question to ask, as I am still novice in this field.
Posted 30 July 2013 - 07:21 AM
Yes, your first assumption is correct - we are saving the entire object.
Note: there is no such thing as a dumb question... and your second point it well made. I don't have to save the entire object, the timing data would be enough. It doesn't really matter which technique is used... although if we had a million athletes, your suggestion would save some RAM!!!
I can see from your questions that you are understanding what's going on here... which is great! :-)
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users