Running (python) script in another directory

I have a python script that generates files. All I want to do is make it write files in a specific folder. Now I have to take 3 steps:

cd foo
python ../awesome_script.py
cd ..

Is there a nice solution where I can do this on a single line using either an external command or directly in the python interpreter?

I am looking for something like:

python -f foo awesome_script.py

or

cd_in_and_out_program foo awesome_script.py

This instruction will be in the makefile afterwards, so it can be ugly.

+4
source share
1 answer

If the problem is just "one line":

cd foo; python ../awesome_script.py; cd ..

will make

+3
source

Source: https://habr.com/ru/post/1649932/


All Articles