And i'm getting the following message : Traceback (most recent call last): File "C:\Sree\Python\test.py", line 6, in -toplevel- testcur=baseCursor1(uname,pwd,dsn) TypeError: 'module' object is not callable
I am trying to learn how to write classes and got stuck with this one.. Any ideas/Suggestions? Thanks a lot..
It's because your python file is called the same as the class you're after. In your test.py file, you're getting the right module but calling the module rather than the class within.
Sorry, I was little late checking my threads. I think you guys are right. I was not using the class name within. I also changed the class name to some other name. It works now.
There's nothing wrong with the class having the same name as the module. There are several cases in the Python library where the main class or main function of a module has the same name as the module.
Also, if you don't like the redundancy on the usage side then you can use the "from" style import:
from baseCursor import baseCursor
testCursor = baseCursor( ... )