'module' object is not callable
-> when module name and class name are confused, this error raised
For example,
I have DBCM class inside dbcm.py and import DBCM class like this,
import dbcm
# do something with dbcm
with dbcm(slef.db_name, sql):
.....
It will raise that typeerror.
How to solve it,
Be clear which one is module and which one is class
from dbcm import DBCM as db_cm
with db_cm(self.db_name, sql):
....
Modified by Keoni Garner - Thank you!:
from dbcm import DBCM
with DBCM(self.db_name, sql):
....
Resource: https://www.stechies.com/typeerror-module-object-is-not-callable/
Top comments (1)
yeah that's right. I thought it's up to the writer whether to write or not. I'm now keeping learning so thank you for ur comment!