user1261046
user1261046

Reputation: 169

How can I resolve Python TypeError: 'module' object is not callable?

I'm trying to write a set of Python classes that would query a database to retrieve some values then construct a network graph. Problem is I get this error whenever I try to call the constructor for one of my classes The relevant code is as follows

class NetworkConstructor:  
def __init__(self):
    self.nodes=dict()
    self.queryservice=QueryService()
    self.graph=networkx.Graph()

And the relevant bits from QueryService class is

def __init__(self):
    self.connect()

def connect(self):
    self.conn=MySQLdb.Connect(host="xxx", port=3306,user="xxx",passwd="xxx",db="xxx")
    self.cursor=self.conn.cursor()

And I have imported all required libraries as well

Upvotes: 1

Views: 3802

Answers (1)

uselpa
uselpa

Reputation: 18917

Looks like your QueryService class is in a module with the same name. Try

self.queryservice=QueryService.QueryService()

Upvotes: 3

Related Questions