1.11M Members

keep os.chdir() after exit?

 
0
 

I want to make Python code to make a new directory then put you into it, same as typing md and cd yourself, but only one command typed. I can use os.chdir() but after Python program exits I return to original directory, not going to new one. How do I change directory and stay there after exit?

 
0
 

Since you enter the Python interpreter, run the program, and then exit the interpreter, I don't think there is a way. The interpreter will always return you to the original directory when it exits. Perhaps someone else will have other ideas on this.

 
0
 

Your code would have to have its own configuration file that it stores the default directory in and then loads on entry.

Jeff

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article