Side question: how do you prevent import statements from being imported by "from lib import star"? (Without explicitly mentioning all the stuff that is not import statements).
For example, this is mymod.py:
import numpy as np
def f(x): return 2*x
And here it is imported:
from mymod import *
f(10) # Works as expected.
np.sum([10, 20]) # Works, but shouldn't work.
The best you can do (without doing crazy introspection) is to set `__all__` in `mymod`. It still requires listing everything you want to be exported from `mymod`, but at least you only need to do it once.
Any non-trivial python module is going to be broken up into multiple files and have an __init__.py which you can explicitly define what's imported and exposed. You can hoist a single file module into a folder-based module if you need direct control and don't want to split it apart into multiple files yet too.
For example, this is mymod.py:
And here it is imported: