471,072 Members | 1,255 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,072 software developers and data experts.

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 1133

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 leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.