This looks like a job for


#1

Ok I am getting a little hung up on what’s happening here. I think I understand most of it, but I have a few questions for clarification.



  def full_time_wage(self, hours):
    return super(PartTimeEmployee, self).calculate_wage(hours)

In the code above, I see that we return .calculate.wage from the superclass, but what I don’t understand is why we put (hours) in for 1, and even if I did understand that why isn’t it (self, hours).

Then on top of that why when I return the superclass, why do I call (PartTimeEmployee, self) - everywhere else “self” has come first, so why second here, and why do I even need to call self, when:

  def full_time_wage(self, hours):

Already calls self?


#2

here:

  def full_time_wage(self, hours):
    return super(PartTimeEmployee, self).calculate_wage(hours)

super()is a function call, someone wrote a function named super, they gave this function parameters, so now when we want to call the function, we need to supply arguments to satisfy the parameters.

remember that if we have functions:

def example(parameter_one, parameter_two)

that we need to supply the arguments in the same order as the parameter

so the super function is designed that we need to supply PartTimeEmployee, self arguments in this order

of course, we can look at the docs:

https://docs.python.org/2/library/functions.html#super

to understand in even more detail


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.