<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
--></style><title>IDLE reading IDLESTARTUP or PYTHONSTARTUP on
restart</title></head><body>
<div>I have a small change (shown below) to PyShell.py in idlelib that
causes the subprocess interpreter to read IDLESTARTUP or PYTHONSTARTUP
each time it restarts. To me this would make IDLE much more useful for
myself and students I teach. It isn't quite clear what behavior
to install with the enabling patch, so I would like some feedback
before submitting it. The main question is:</div>
<div><br></div>
<blockquote>Shouldn't IDLE<i> always</i> read IDLESTARTUP (if defined)
or PYTHONSTARTUP (if IDLESTARTUP is not defined and PYTHONSTARTUP is)
when it starts rather than that requiring a command-line switch as it
does now? This is the behavior of python, and I don't see why it
should be any different for IDLE. More importantly, there is no
convenient way to say "and read my startup file" when
double-clicking the IDLE icon. (I'm on a Mac. On Windows the -s switch
could be added to an icon for IDLE, but that's still
awkward.)</blockquote>
<blockquote><br></blockquote>
<div>Secondary questions;</div>
<blockquote><br></blockquote>
<blockquote>If IDLE is changed to read a startup file, should the -s
switch be dropped altogether? If so, should a -q switch be added (as
with emacs) to start<i> without</i> loading the startup file? I think
yes to both.</blockquote>
<blockquote><br></blockquote>
<blockquote>When the subprocess interpreter is restarted should it
look in the environment for the current values of IDLESTARTUP and
PYTHONSTARTUP, or should IDLE store those values in a property of the
subprocess interpreter when first started and have restart go directly
to the saved path even if the value of IDLESTARTUP or PYTHONSTARTUP
has changed since IDLE had been started. I think restart should go to
the path as it was when IDLE was started and ignore subsequent
changes. Or at least the reststart should notice the change and
present a dialog asking the user to choose between the old path and
the new one.</blockquote>
<div><br></div>
<hr>
<div>The diff modifies PyShell by copying the four lines of code that
load IDLESTARTUP or PYTHONSTARTUP from where they appear in the
initial startup code and adding to where the subprocess interpreter
writes "RESTART" to the console.</div>
<div><br></div>
<div>@@ -434,6 +434,10 @@<br>
console.write(halfbar
+ ' RESTART ' + halfbar)<br>
console.text.mark_set("restart", "end-1c")<br>
console.text.mark_gravity("restart", "left")<br>
+ filename =
os.environ.get("IDLESTARTUP") or \<br>
+ <span
></span>
os.environ.get("PYTHONSTARTUP")<br>
+ if filename and
os.path.isfile(filename):<br>
+
self.execfile(filename)<br>
console.showprompt()<br>
# restart subprocess
debugger<br>
if debug:</div>
</body>
</html>