Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: changing IDLE's path in WIN7 [duplicate]

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,

like image 509
597936 Avatar asked May 22 '11 10:05

597936


1 Answers

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('.')
like image 80
Vincenzo Pii Avatar answered Oct 06 '22 20:10

Vincenzo Pii