İçereği Atla
Menü
Bu soru işaretlendi

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
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
2
Ara 22
3331
8
Eki 24
23488
1
Tem 23
2510
3
May 21
14000
4
Oca 19
3901