-CON: Directory name is xonsh. Explicit relative imports within this package fail since 'xonsh' package now exists 2 times.
2) (My preference) Add 'sys.path.append("/home/<username>/.config/")' in ~/.xonshrc
Create directory/package xonsh_config inside .config and import from there
-CON: This it NOT default. Normally I always prefer to keep default behavior instead.
-CON: subdirectories in .config are normally always <PROGRAM/LIBRARY NAME>. This fucks up (an unspoken) convention.
-PRO: I think there's an environment variable in xonsh which defines it's configuration directory (which is .config/xonsh by default)
-PRO: Now you don't encounter issues when importing from xonsh package. xonsh and xonsh_config are now clearly distinguished.
3) (Would be nice if it worked :). It would be nice if .config was by convention not a hidden directory. It would then be possible to use for every python program: 'from config import ...'. But this doesn't work for hidden dirs... and since .config and rc files are kinda very stable conventions, I don't want to change it.
I prefer 2) because I prefer adding tests on whatever I write. Got a 'test.py' and 'log.py' which import modules from both 'xonsh' and 'xonsh_config' package. Testing before implementation is useful when using xonsh as primary shell :)
B. About reloading:
Use 'from importlib import reload'. Use it as you wish! As an example, I got the following piece in .xonshrc to reload an 'on_precommand' function every time before I issue a command
import xonsh_config.ntwuk
def ntwuk_wrapper(cmd, **kwargs):
reload(xonsh_config.ntwuk)
return xonsh_config.ntwuk.on_precommand(cmd, **kwargs)
events.on_precommand(ntwuk_wrapper)
Hopefully this may provide some useful insights
Gtz,
Dieter