changing directory whist running python code -


this question has answer here:

i have piece of code runs 4 other pieces of code. when codes run write out put writes directory run code in. wondering if there way run code changes directory after every time, here code:

loop=np.arange(187761,187854) ext in loop:  ext=str(ext)  s0=''   dcom=["rm *.txt"]  dcom=s0.join(dcom)  nes=os.system(dcom)   a=sys.argv[1]  com=['cd /cygdrive/e/desar2.cosmology.illinois.edu+7443/desfiles/desardata/ops/red/', a,'/red/decam_00',ext, '/']  com=s0.join(com)  print com  sres=os.system(com)   com=['python /home/pythoncodes/other4.py ', '00'+ext]  com=s0.join(com)  print com  sres=os.system(com)   com=['python /home/pythoncodes/correctedmo.py ', '00'+ext]  com=s0.join(com)  print com  sres=os.system(com)   com=['python /home/pythoncodes/graphs.py ', '00'+ext]  com=s0.join(com)  print com  sres=os.system(com)   com=['python /home/pythoncodes/whiskerother4.py ', '00'+ext]  com=s0.join(com)  print com  sres=os.system(com) 

i hoping top part change directory every ext, doesn't. there way or should alter programs write different directories?

you can use os.chdir(path) change current directory.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -