Hello,

Here is a very basic question, but it is frustrating me to no end 
nonetheless.

I have one file called addLink.py. In a method in this file I am trying 
to instantiate a class and call a method from that class. Here is the code:

def getCategories():
        # instantiate the DataUtil class
        db = DataUtil()
        # and call the getConnection() method
        connection = db.getConnection()
                
        ...

At the top of this file I am importing the DataUtil module (named 
DataUtil.py) with this line:

import DataUtil

The DataUtil.py file resides in the same directory as the above file and 
looks like this:

import MySQLdb

class DataUtil: 
        def __init__(self):
                print "init"

        def getConnection(self):
                return MySQLdb.connect(host="host", user="user",                
        passwd="pass", 
db="test")

When I execute the getCategories() method above I get the following error:

   File "C:\Apache2\htdocs\Intranet\addLink.py", line 42, in getCategories
     db = DataUtil()

TypeError: 'module' object is not callable


Any idea what I'm doing wrong?

Thanks,

Dave

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to