468,249 Members | 1,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Can't instantiate class

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

Nov 6 '05 #1
0 1079

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by jerrygarciuh | last post: by
1 post views Thread by Jason Lopez via .NET 247 | last post: by
5 posts views Thread by Pyenos | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.