Override!


#1

So, I got the right answer, but I don't understand the difference between the two and why one works and the other doesn't.

Why this?

class PartTimeEmployee(Employee):
    def __init__(self, hours):
        self.hours = hours
        return hours * 12.00

And not this?

class PartTimeEmployee(Employee):  
    def calculate_wage(self, hours):
        PartTimeEmployee.calculate_wage = employee.calculate_wage
        self.hours = hours
        wage = PartTimeEmployee.hours * 12.00
        return wage

What does the __init__ do? Like, I know it's short for "initialize", but I'm a total derp.


#2

Methods surrounded by double underscores are "magic" names, they have special meaning in the language.

__init__ is automatically called when an instance of the class is created.

calculate_wage should do some math, it shouldn't change the object, that would be an unadvertised side-effect.