Reputation: 364
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.
Upvotes: 0
Views: 50
Reputation: 34056
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()
Upvotes: 2