Hyun Jun Jung's Content

There have been 1 items by Hyun Jun Jung (Search limited from 17-December 16)

By content type

See this member's

Sort by                Order  

#129169 Chapter 6, Athlete Class Question

Posted by Hyun Jun Jung on 07 August 2015 - 10:20 PM in Head First Python

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