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

Change directory (commandline window)

Ok, for some strange reason I cannot move from the "Python27" folder:
I have tried this...

Python 2.7.3 (default, Apr 10 2012, 23:31:26) 
Type "help", "copyright", "credits" or "license" for more information.

>>> from os import system
>>> system('cd')
C:\Python27
0
>>> system('cd ..')
0
>>> system('cd')
C:\Python27
0

It did not change directory; why?

4
Contributors
2
Replies
5 Hours
Discussion Span
11 Months Ago
Last Updated
3
Views
HTMLperson5
Deleted Member

The system has it's own current dictionary, you want to change Python's directory by os.chdir

pyTony
pyMod
Moderator
6,312 posts since Apr 2010
Reputation Points: 879
Solved Threads: 987
Skill Endorsements: 26

os.system() is a (deprecated) function to run another program from your python program. Changing your process' working directory is different from starting another program. Use os.chdir(path) to change the current working directory and os.getcwd() to get the current working directory.

Gribouillis
Posting Maven
Moderator
3,101 posts since Jul 2008
Reputation Points: 1,130
Solved Threads: 761
Skill Endorsements: 11

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

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0916 seconds using 2.65MB