Default save path for Python IDLE?

python, python-idle

Solution

On OS X, if you launch `IDLE.app` (by double-clicking or using `open(1)`, for example), the default directory is hardwired to `~/Documents`. If you want to change the default permanently, you'll need to edit the file `idlemain.py` within the IDLE.app application bundle; depending on which Python(s) you have installed, it will likely be in one of:

/Applications/MacPython 2.x/IDLE.app/Contents/Resources
/Applications/MacPython 2.x/IDLE.app/Contents/Resources
/Applications/MacPorts/Python 2.x/IDLE.app/Contents/Resources
/Applications/Python 2.x/IDLE.app/Contents/Resources
/Applications/Python 3.x/IDLE.app/Contents/Resources

Edit the line:

os.chdir(os.path.expanduser('~/Documents'))

On the other hand, if you start IDLE from the command line, for example, with:

$ cd /some/directory    
$ /usr/local/bin/idle

IDLE will use that current directory as the default.

Problem

Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level `~/Documents directory`. I would like to specify a real location. Any ideas?

Original source

Related problems