Jump to content


Photo

Chap 7 Pg 224


  • Please log in to reply
1 reply to this topic

#1 vac79

vac79

    New Member

  • Members
  • Pip
  • 1 posts

Posted 24 July 2013 - 12:02 AM

Hi,

I have started with programing and first time learning OOPS.

My question is with regards to the code shown on page 224.

ath=get_coach_data(each_file)

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

all_athletes[ath.name]=ath.times

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.


Thanks
Vishal

#2 paulbarry

paulbarry

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

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! :-)

--Paul.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users