Ir al contenido
Menú
Se marcó esta pregunta

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
Descartar
Publicaciones relacionadas Respuestas Vistas Actividad
2
dic 22
3205
8
oct 24
23001
1
jul 23
2406
3
may 21
13897
4
ene 19
3901