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()
?
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.