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

1

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,

Hills answered 22/5, 2011 at 10:43 Comment(1)
Just a note that duplicate question (#8248897) has been asked after my question. Nothing big - just mentioning.Hills
I
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('.')
Incogitable answered 22/5, 2011 at 10:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.