My older structure is:
In a file, I'm doing:
from CodeModel import CodeModel codemodel = CodeModel.CodeModel() But that seems redundant. Is there a cleaner way to import CodeModel without having to do CodeModel.CodeModel()?
from CodeModel.CodeModel import CodeModel but you should think of different packages&modules structure because it may indeed be redundant.
If you have multiple (but not really many) models, think of creating modules.py with CodeModel and other model classes. Simplify things if possible (adequatly to project's size).
from models import CodeModel seems better, doesn't it?
Another option would be
from .CodeModel import CodeModel inside __init__.py of CodeModel package, already mentioned in the comment by Patrick Haugh.
from CodeModel.CodeModel import CodeModel;-)from .CodeModel import CodeModelin your__init__.py. Thenfrom CodeModel import CodeModelfrom outside the package will import the class. (You should probably give the packages, modules, and classes different names though, or it quickly becomes very confusing)CodeModel.pyeven in a package calledCodeModel? There seems to be nothing else in it. Just remove that package.CodeModel