I'm having a hard time grasping the variables inside a method of a Class, and am seeking an explanation of how these work, to help me better understand it.
For example:
inside Time class
def __init__(self, hour,minute, second)
self.hour = hour
self.minute = minute
self.second = second
def print_time(self):
print '%.2d:%.2d:%.2d' % (self.hour, self.minute, self.second)
time = Time(h,m,s)
time.print_time()
Where does the change in variable for 'self' occur? Why isn't the method called (what would seem more straight-forward) as: method(var1(subject), var2, var3, var4)? instead of subject.method(var2, var3, var4)? (I know my understanding of this is shaky, and I'm happy to receive corrections if any of my terms are incorrect).
self.x = hour— there is nohourin the available scope. What isprint_time? Where is the class definition?