472,954 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Can't instantiate class


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

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",

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?



Nov 6 '05 #1
0 1215

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: jerrygarciuh | last post by:
Hello, Is it possible to instantiate a child class within the constructor of its parent? eg Class DBI extends DB { function DBI() { // explicit parent constructor call
by: Glenn Serpas | last post by:
I have Class A and Class B .. Class B has a private member that is a pointer to a Class A object. private: B *mypointer ; I instantiate the A object A* myobject new = A();
by: Jason Lopez via .NET 247 | last post by:
I'm having a lot of trouble trying to instantiate a C++ classfrom a DLL in a C# application. The DLL was written in C++(Visual Studio 6.0). I have the full source code, as well as the compiled...
by: Ron | last post by:
Hello, I need 2 projects/apps to communicate with each other. I figured out how to create a Class Library project with a form and how to add a new exe project to the solution. I set the...
by: downwitch | last post by:
Either I don't understand (entirely possible), or there's no way to copy parts of a class hierarchy from one instance to another. Say I have a class called Foo, and it contains, among other...
by: Pyenos | last post by:
class One: Two() #can't instantiate class Two: Three() #can't instantiate class Three:pass
by: Grizlyk | last post by:
Grizlyk wrote: I need to point self class in template parameter, for example template < class Tptr, class Tc_iterator class Vcontainer { public:
by: Tomas | last post by:
A newbie question: How can I instantiate objects dynamically in VB.NET. E.g. I have the object 'Player' and I would like to instantiate it with the several instances (James, Gunner, etc.), without...
by: Joe Strout | last post by:
I have a function that takes a reference to a class, and then instantiates that class (and then does several other things with the new instance). This is easy enough: item = cls(self,...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.