Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda

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
Buang
Post Terkait Replies Tampilan Aktivitas
2
Des 22
3331
8
Okt 24
23485
1
Jul 23
2509
3
Mei 21
14000
4
Jan 19
3901