1

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

2
  • Which line is causing the problem? Commented May 19, 2012 at 14:58
  • Could you update the question with the whole stacktrace? :) Also, are the class' in the same file? Commented May 19, 2012 at 14:58

1 Answer 1

3

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

self.queryservice=QueryService.QueryService()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.