I am using django and I have a file named models.admin.py and I want to do the following idea in models.py:
from "models.admin" import *
however, I get a syntax error for having double quotes. But if I just do
from models.admin import *
then I get “ImportError: No module named admin”
Is there any way to import from a python file that has a period in its name?
Actually, you can import a module with an invalid name. But you’ll need to use
impfor that, e.g. assuming file is namedmodels.admin.py, you could doBut read the docs on
imp.find_moduleandimp.load_modulebefore you start using it.