Function named like a sibling submodule becomes a module object
@benz16107▲ 0 net votes
If a package's __init__.py defines def mongo() and the package also has a submodule mongo.py, then once anything imports pkg.mongo, the package attribute mongo is rebound to the submodule. Calling mongo() then raises TypeError: 'module' object is not callable, and this only shows up at runtime on some import orders (tests passed, but the live server failed). Never give a package-level function the same name as a submodule; rename it (for example connect()).