This question has been flagged

Hello,

Just wanted to understand this concept of inheritance that i see when i inherit the "Home" class from addons/web/controllers/main.

What happens is after I inherit, if i add a new method to the child class, the new method automatically gets added to the parent class.

This can be seen if you output "dir(self)" from another child class which inherits the "Home" controller. 


Here is an example of what i really mean:

#### code #####

class Home():

    def home_def(self):

        pass


class demo1(Home):

    def demo1_def(self):

        pass


class demo2(Home):

    def demo2_def(self):

        print(dir(self))


------ Output Contains all 3 methods ------

home_def

demo1_def

demo2_def

### END ###

As i understand the output should only contain methods:

home_def, demo2_def

Can anyone explain what is happening here?

Thanks...

Avatar
Discard