6

Windows 7 As I'm learning Python (3.2) I prefer using IDLE than CMD. In order to change the path where I can import scripts of my own, I use a little trick that I found in this site: I go FILE>OPEN>directory>myscript and then run it and from then on I'm on this directory.

Nevertheless, I wonder whether there is a simple command, like CD... to move to the correct directory, without using tricks.

Thank you,

597936
  • 63
  • 1
  • 4
  • Just a note that duplicate question (http://stackoverflow.com/questions/8248397/how-to-know-change-current-directory-in-python-shell) has been asked after my question. Nothing big - just mentioning. – 597936 Mar 20 '14 at 20:16

1 Answers1

6

http://www.skylit.com/python/Appendix-A.html

Check section A.2, just before section A.3:

>>> from os import chdir
>>> chdir("C:/myOtherWork")

And also to check the working directory:

>>> from os.path import abspath
>>> abspath('.')

If the current directory is not already in the path you need to add it:

>>> import sys
>>> sys.path.append('.')
Vroo
  • 1,064
  • 1
  • 11
  • 19
Vincenzo Pii
  • 18,961
  • 8
  • 39
  • 49