Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata

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
Abbandona
Post correlati Risposte Visualizzazioni Attività
2
dic 22
3331
8
ott 24
23506
1
lug 23
2515
3
mag 21
14003
4
gen 19
3901