We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,489 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

keep os.chdir() after exit?

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?

3
Contributors
2
Replies
1 Day
Discussion Span
5 Years Ago
Last Updated
3
Views
Miyuki
Newbie Poster
11 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

woooee
Posting Maven
2,707 posts since Dec 2006
Reputation Points: 827
Solved Threads: 780
Skill Endorsements: 9

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

Jeff

jrcagle
Practically a Master Poster
608 posts since Jul 2006
Reputation Points: 92
Solved Threads: 160
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0571 seconds using 2.66MB