Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to specify default directory for saving files in Python IDLE

Status
Not open for further replies.

JohnJohnUSA

Programmer
Jul 2, 2006
3
US
I am using Python IDLE 2.4.3 on Windows XP. I use File ->New Window to create a new program. In the Save As dialog, it always takes me to the python program directory (where python is installed). Since this is not where I want to save my source file, I have to select the directory I want.

Is there a way that I can have python always bring up the Save As dialog pointing to the directory of my choice? In other words, I would like to specify what I want the default directory for saving files to be.

In addition, is there a way to get IDLE to add the extension .py to the file name in the Save As dialog without my having to type it each time?

Thank you in advance for your help!
 
The fastest solution is to hack IDLE -- edit the IOBinding.py ( in my Python 2.4.3 installation C:\python24\Lib\idlelib\IOBinding.py ):

change lines 181 & 182 to
Code:
    filename = ".py"   # old value is "" 
    dirname = "e:\\"   # old value is None; change e:\ to directory of your choice


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top