Running python script

I would like to execute a script work.pyin Python after doing some initialization of the script init.py.

If I were looking for an interactive session, the execution python -i init.pyor installation PYTHONSTARTUP=/path/to/init.pywould do the trick, but I want to execute another script.

Since this is the general case, which often occurs ( init.pysets the environment and, therefore, one and the same), I would prefer not to refer to init.pyon work.py. How can I do that? Will anything change if I need this from a script instead of an invitation?

Many thanks.

+5
source share
2 answers

, C0deH4cker, Python 2.2.5 - Cusomization. , script, Python, . :

>>> import site
>>> site.getusersitepackages()
'/home/user/.local/lib/python3.2/site-packages'

, sitecustomize.py.

+5

Python script, . /usr/lib/python2.5/site-packages/sitecustomize.py IIRC. , init.py sitecustomize.py script, , init.py sitecustomize.py.

+4

All Articles