Jump to content

Hyun Jun Jung

Member Since 07 Aug 2015
Offline Last Active Aug 08 2015 02:57 AM

Topics I've Started

Chapter 6, Athlete Class Question

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...