I have a package with files, each file has a class:
model
-- User.py
-- Project.py
-- Item.py
-- __init__.py
inside __init__.py
I have this:
from os.path import dirname, basename, isfile
import glob
modules = glob.glob(dirname(__file__)+"/*.py")
__all__ = [ basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')]
as explained inside this answer: https://stackoverflow.com/a/1057534/2337243
Now my problem is:
I can now use the imported classes in another class but only by doing this:
from model import *
results = session.query( User.User).all()
My question is: how do I import the model classes and simply call the classes like this:
results = session.query( User).all()
N.B: each file inside model package has one single class that has the same name as the file name.