Here I just want to discuss the example they gave us at left console
I am not very clear with the code below:
ceo = CEO("Emily") # which attributes was assigned with the value " Emily " ? the one in class CEO or the one in class Employee ?
emp = Employee("Steve")
emp.greet(ceo) #What does this line mean ?
ceo.greet(emp) # the same as above
and why it does not print anything at first two lines above but return the words at last two lines?
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!