iPython notebook automatically switches the directory to the same file as the .ipynb file. Do you want to change this directory and then change it later? If so, just save the source directory at the beginning of the program and use it whenever.
import os orig_dir = os.getcwd() os.chdir('/some/other/directory')
EDIT: A special variable _dh , which is a list, so that _dh[0] contains the name of the directory in which the iPython kernel was run. I just opened this, so I'm not sure if this will be reliable for SaveAs (I cannot find a way to do this in my version of iPython). However, this does not change when I do os.chdir() , so I suspect that at least the first element of the list always contains a notebook directory.
source share