Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a (python) script in another directory [duplicate]

I have a python script, which generates files. All i want is to force it to write the files in a specific folder. Right now i have to do 3 steps:

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

Is there any nice solution, where i can do this in one line, either using some external command, or directly in the python interpreter?

I am searching for something like:

python -f foo awesome_script.py

or

cd_in_and_out_program foo awesome_script.py

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

like image 596
hr0m Avatar asked Oct 30 '22 22:10

hr0m


1 Answers

If the problem is just "one line":

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

will do

like image 168
Ohad Eytan Avatar answered Nov 02 '22 11:11

Ohad Eytan