How to import all things defined the files in a module directory in __init__.py?
Peng Yu
pengyu.ut at gmail.com
Wed Sep 21 23:53:06 EDT 2016
Hi,
Suppose that I have file1.py, ..., filen.py in a module directory.
I want to import all the thing (or the ones available in the
respective __all__) defined in each of the file by putting the
following lines in __init__.py
from file1 import *
....
from filen import *
However, I don't want to hardcode the file names in __init__.py. Is
there an automatic way of doing it?
--
Regards,
Peng
More information about the Python-list
mailing list