Mar-25-2017, 10:14 AM
Beside dot meaning relative import,
You can use/abuse
Example (with big help of importlib docs)
import something
creates variable something
and variable names cant start with a dot.You can use/abuse
importlib
library to load module from a file and execute it, make it importable and import it (for python 3.?+, older ones use imp?).Example (with big help of importlib docs)
Output:jacq /tmp> cat .boo.py
print('boo')
def boo():
print('boo boo')
>>> import sys >>> import importlib.util as imput >>> spec = imput.spec_from_file_location('boo', '.boo.py') >>> boo_module = imput.module_from_spec(spec) >>> spec.loader.exec_module(boo_module) boo >>> sys.modules['boo'] = boo_module >>> import boo >>> boo.boo() boo booBut doing such thing just to have hidden config file seems be a little exaggerated. Is not better to put your config file to some hidden directory (like ~/.config/skapeutil), modify sys.path and import it in a standard way?