Can't instantiate class

David Mitchell dave at dbmdata.com
Sun Nov 6 09:47:04 EST 2005


Thanks for your prompt reply.

Ok, so If use your first suggestion (db = DataUtil.DataUtil()
), I get this error:

AttributeError: 'module' object has no attribute 'DataUtil'

If I try importing the class directly (from DataUtil import DataUtil), 
I get this error:

ImportError: cannot import name DataUtil


Could these errors have something to do with the fact that I am doing 
this through mod_python?

Thanks again,

Dave

Michael P. Soulier wrote:
> On 11/6/05, David Mitchell <dave at dbmdata.com> wrote:
> 
>>import DataUtil
>>
>>   File "C:\Apache2\htdocs\Intranet\addLink.py", line 42, in getCategories
>>     db = DataUtil()
>>
>>TypeError: 'module' object is not callable
> 
> 
> You've imported module DataUtil, and by calling DataUtil(), you're
> trying to call the module, hence the error. I think you want
> 
> db = DataUtil.DataUtil()
> 
> Or,
> 
> from DataUtil import DataUtil
> 
> And then your code will work.
> 
> Mike
> 
> --
> Michael P. Soulier <msoulier at digitaltorque.ca>
> 



More information about the Python-list mailing list