Jump to content


Chapter 6, Athlete Class Question

  • Please log in to reply
No replies to this topic

#1 Hyun Jun Jung

Hyun Jun Jung

    New Member

  • Members
  • Pip
  • 1 posts

Posted 07 August 2015 - 10:20 PM

Hi I am having a strance trouble in Athlete class in chap6


I typed pretty much same as written in the book:


class Athlete:


   def __init__(self, a_name, a_dob = None,  a_times = []):

      self.name = a_name

      self.dob = a_dob

      self.times = a_times


   def add_time(self, time_value):



   def add_times(self, list_of_time):




Yes.. It works fine.... However, as soon as I use method

add_time or add_times, its __init__ method is changed for no reason


before using the methods when I type




__init__(self, a_name, a_dob = None, a_times = []) # It seems fine




however after use the methods

>>>jung = Athlete('jung')




__init___(self,  a_name, a_dob=None, a_times = ['1.11'])



init method is changed, so that whenever I create other Ahtlete class


>>john = Athlete('john')




even before I add anything to times, it has initial value which I used in add_time or add_times method before....


>>james = Athlete('james')


>>kate = Athlete('kate')




I don't know why this happening...

Edited by Hyun Jun Jung, 07 August 2015 - 10:21 PM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users