I have mentioned the code snippet below. I think that the explanation to the code is extremely vague particularly since i have seen most examples dissected and explained exhaustively. For example, I would like the reader to kindly explain what happens when
ceo = CEO("Emily") is created. To what does the string "Emily" bind itself to?
What happens when
emp.greet(ceo) is called?
What's happening with the variables in each of the function call?
class Employee(object): def __init__(self, name): self.name = name def greet(self, other): print "Hello, %s" % other.name class CEO(Employee): def greet(self, other): print "Get back to work, %s!" % other.name ceo = CEO("Emily") emp = Employee("Steve") emp.greet(ceo) # Hello, Emily ceo.greet(emp) # Get back to work, Steve!