1,105,371 Community Members

keep os.chdir() after exit?

Member Avatar
Miyuki
Newbie Poster
11 posts since Mar 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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?

Member Avatar
woooee
Posting Maven
2,793 posts since Dec 2006
Reputation Points: 783 [?]
Q&As Helped to Solve: 836 [?]
Skill Endorsements: 12 [?]
 
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.

Member Avatar
jrcagle
Practically a Master Poster
608 posts since Jul 2006
Reputation Points: 77 [?]
Q&As Helped to Solve: 160 [?]
Skill Endorsements: 0 [?]
 
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 three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article