You could (and probably should) make this an IDLE extension. This will increase the chance that your changes will work with future changes in IDLE, and allow you to easily implement (and debug!) such changes when they will be required. For instance, you could easily switch your extension on or off in a config file, instead of running a different version of IDLE.
<br><br>For info on writing extensions, read the &quot;extend.txt&quot; file in Lib\idlelib\, and check out the code of existing extensions (FormatParagraph and CodeContext are good examples).<br><br>For a taste - when writing an extension, you write a class whose contructor recieves the EditorWindow instance as an argument. PyShell is a subclass of EditorWindow, so your extension will actually be recieving the PyShell instance, which you can change you your liking.
<br><br>Also, you should use idleConf to save/load configuration; idleConf has an &#39;extensions&#39; section specifically for IDLE extensions. So you could write file&#39;s default location in config-extensions.def, and each user can choose a location of his choice in his 
config-extensions.cfg.<br><br>You can easily configure an extension to be enabled only for Shell windows by writing &quot;enable_editor=0&quot; in config_extensions.def.<br>
<br><br>Caveat: Writing paths in IDLE&#39;s config files requires reading/writing them as &quot;raw&quot; values, which idleConf currently doesn&#39;t allow. I have a simple patch which allows idleConf to do this, but I sent it along with a patch for the Squeezer IDLE extension, which hasn&#39;t been accepted yet. I could create a patch just for idleConf if you&#39;d like.
<br><br>Currently extension config is done by manually editing the above mentioned text files, but you mentioned wanting to specifiy the session file inside IDLE. I have written a generic configuration dialog for IDLE extensions which allows extension configuration inside IDLE, but I haven&#39;t posted it as a patch yet (not polished enough). Again, I could send you a working version if you like.
<br><br><br>You also mentioned wanting IDLE to prompt the user if the session hasn&#39;t been saved. Notice that IDLE does this when editing files. This is because the EditorWindow class defines a maybesave() method which does this, but OutputWindow (a subclass of EditorWindow, which PyShell inherits) overrides this method. You could override PyShell&#39;s maybesave() method with something similar to EditorWindow&#39;s method.
<br><br>EditorWindow.maybesave() actually calls IOBinding.maybesave()... which does a lot of work for you (such as remembering the filename, prompting for a filename if the buffer has never been saved, etc.). Not sure if this is exactly the functionality you want, but it&#39;s a starting point.
<br><br><br>I hope all this helps! (and that we have an awesome new IDLE extension soon :)<br><br>Good luck,<br>- Tal<br><br><br><div><span class="gmail_quote">On 1/15/07, <b class="gmail_sendername">Saul Spatz</b> &lt;<a href="mailto:sspatz@kcnet.com">
sspatz@kcnet.com</a>&gt; wrote:</span> <br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">&gt; On 12/27/06, Saul Spatz &lt;<a href="mailto:sspatz@kcnet.com">
sspatz@kcnet.com</a>&gt; wrote:<br>&gt;&gt;<br>&gt;&gt; I am rather new to both python and IDLE.&nbsp;&nbsp;The references to IDLE at<br>&gt;&gt; <a href="http://www.python.org">www.python.org</a> seem sadly out-of-date.&nbsp;&nbsp;I have a couple of simple
<br>&gt;&gt; enhancements I would like to make to IDLE that are not likely to be of<br>&gt;&gt; general interest.&nbsp;&nbsp;(I want to use IDLE in teaching, and I want to save<br>&gt;&gt; the sessions, both user input and IDLE output.&nbsp;&nbsp;I would like IDLE to
<br>&gt;&gt; remember where I saved the last session and default to that directory,<br>&gt;&gt; and I would like it to prompt me if I close the IDLE window without<br>&gt;&gt; having saved the session.)&nbsp;&nbsp; It seems like these should be easy to
<br>&gt;&gt; program, but I can&#39;t find the IDLE source.<br>&gt;&gt;<br><br>Thanks.&nbsp;&nbsp;I think I&#39;ve figured out how to modify IDLE to do what I want.<br>Now, I&#39;m having trouble figuring out how best to organize my changes so
<br>they don&#39;t get clobbered by the next IDLE update.&nbsp;&nbsp;I&#39;m trying to work<br>out how best to deal with packages and python namespaces.&nbsp;&nbsp;Here is a<br>sample of what I have worked out:<br><br>#idle2.pyw<br><br>import 
idlelib.PyShell<br>import time<br>from Tkinter import *<br>EditorWindow = idlelib.EditorWindow.EditorWindow<br><br>class MyPyShell(idlelib.PyShell.PyShell):<br>&nbsp;&nbsp;&nbsp;&nbsp;def close2(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;format = &#39;%d%b%Y.%H%M%S.log&#39;
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path = &quot;E:/MyPythonProjects/&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filename = path + time.strftime(format)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log = open(filename,&#39;w&#39;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.write(self.text.get(1.0,END))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
log.close()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;except IOError:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pass<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return EditorWindow.close(self)<br><br>idlelib.PyShell.PyShell = MyPyShell<br>idlelib.PyShell.main()<br><br>This seems to work.&nbsp;&nbsp;However, I don&#39;t really want the path to be
<br>hard-coded into my program.&nbsp;&nbsp;I want to be able to select the directory,<br>and to control the logging behavior interactively.&nbsp;&nbsp;This means that I<br>will have to subclass ConfigDialog.ConfigDialog and perhaps other<br>
classes as well.&nbsp;&nbsp;Am I likely to run into trouble with the approach<br>indicated above, and, in any case, is there a better way?<br><br>I realize that this question has little to do with IDLE development, but<br>I don&#39;t know where else to turn for help.&nbsp;&nbsp;I&#39;d be grateful if some guru
<br>will give of his wisdom to a beginner.<br><br>Thanks,<br>Saul<br><br></blockquote></div><br>