Member Avatar

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?

Recommended Answers

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

Jump to Post

All 2 Replies

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.