0

I am having a difficult time trying to figure out the correct way on how to call methods inside a method that happens to be in a different class.

Here's my code:

runner,py

import reader as bb



class monitorRunner():

  def __init__(self):
    self.url = sys.argv[1]
    self.store = None
  
  def executeLink(self):
    self.determineStore()
    bb.BestBuyMonitor.executeBestBuyMonitor(self,self.url,self.store)

  def determineStore(self):

    -code-
  

if __name__== "__main__":
    taskMaster =  monitorRunner()
    taskMaster.executeLink()

reader.py

class BestBuyMonitor():

  def __init__(self):
    -variables-


  def executeBestBuyMonitor(self,store,url):
    self.getAPiData()
  
  def getAPiData(self):
    -code-

Trace:

self.getAPiData()
AttributeError: 'monitorRunner' object has no attribute 'getAPiData'

Not quite sure how to fix this, any help would be appriciated.

1
  • 1
    You must instantiate the class! BestBuyMonitor().executeBestBuyMonitor(...). Commented Mar 27, 2021 at 7:06

1 Answer 1

2

You missed instantiating the class. Use () after class's name:

import reader as bb



class monitorRunner():

  def __init__(self):
    self.url = sys.argv[1]
    self.store = None
  
  def executeLink(self):
    self.determineStore()
    bb.BestBuyMonitor().executeBestBuyMonitor(self.store,self.url)

  def determineStore(self):

    -code-
  

if __name__== "__main__":
    taskMaster =  monitorRunner()
    taskMaster.executeLink()
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for you help, once doing this change it returns as TypeError: executeBestBuyMonitor() takes 3 positional arguments but 4 were given..
Check my updated answer. Remove self from executeBestBuyMonitor().

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.