Create an Instance of One Class from Another Class [Closed]

I created browserView class named as "bdrMenuView" . It should be like "class bdrMenuView(BrowserView):" . and the class contains the method named as "createPictMenu" . The whole class should be

    class bdrMenuView(BrowserView):
              def createPictMenu(self):

Now i have written one more class named as LogoViewlet . It should be like "class LogoViewlet(ViewletBase):" . and the class contains the method named as "update" . The whole class should be

    class LogoViewlet(ViewletBase):
              def update(self):

Now i want to call the method of browserView class from another class. I created an instance of one class like

    class LogoViewlet(ViewletBase):
              def update(self):
                   a = bdrMenuView(self,BrowserView)      ---------> instance of BrowserView class
                   logoName = a.createPictMenu() 

I want to know whether it is correct or not which i created.

3

create an instance class from an another class

class LogoViewlet(ViewletBase):
          def update(self):
               a = bdrMenuView(self,BrowserView)   --->>>> this is wrong. no need to pass BrowserView as a parameter   
               logoName = a.createPictMenu() 



class LogoViewlet(ViewletBase):
          def update(self):
               a = bdrMenuView(self.context,self.request) --->>>> this is the correct way to create an instance of one class     
               logoName = a.createPictMenu() 
David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest