13/18 New rule in Inheritance


#1



https://www.codecademy.com/en/courses/python-intermediate-en-WL8e4/2/3?curriculum_id=4f89dab3d788890003000096


From the code below, in greet function what is the purpose of other object?. This other.name seems to be new rule in this inheritance example. Not explained anywhere about this rule.

How the other.name works?


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


#2

other is just a variable for any employee object - the greet method needs 2 employees to greet. fe:

employee.greet(boss) - the first (employee) is greeting the other (boss)
print boss.name - with this you can check boss' name