Re: [Tutor] very basic question from a newbie

Magnus Lycka magnus at thinkware.se
Wed Feb 11 12:49:44 EST 2004


> I just read "IDLE Introduction --- One Day of IDLE Toying".  It was great because it was so basic and helped me get started.  My first couple of test "modules" ran just fine, but all of a sudden IDLE started "hanging" for a long time every time I click on "Run Module".  Just running the following module seems to freeze the video on my computer for about 15 seconds.

In my experience, IDLE gets slow if there is a lot of data, particularly
long lines of text, in the interactive interpreter window. It doesn't 
matter if this text is far out of sight. I assume this is a "feature" 
of the underlying Tk GUI.

I.e. if you have done something like calculated the factorial of large 
numbers over and over again, or done prints in long loops etc, you can
expect IDLE to be slow until you restart it.

>From Python 2.3 under Windows I also feel that I've had problems with
dead (or at least lost) python or pythonw processes floating around. If
you are using Windows NT / 2000 / XP you can use the task manager to see
these (under the processes tab) and kill them. Just don't kill your
current IDLE editor window if you have unsaved work. :)

There are other Python IDEs and editors than IDLE. The selection depends 
on your OS. For instance, on Windows there is PythonWin which comes with 
the win32all extensions, and is included in ActivePython. See
http://www.python.org/cgi-bin/moinmoin/PythonEditors and
http://www.python.org/cgi-bin/moinmoin/IntegratedDevelopmentEnvironments
for plenty of other examples.

You probably get the best performance if you run Python scripts from your
command line. I often have a Command Prompt (cmd.exe) open in Windows and
start my program from there after having saved in the editor. Restarting
after a new editing cycle is just a matter of saving in the editor, swapping
to the command prompt with Alt-Tab and pressing Up-Arrow follows by Enter.


> >>> ================================ RESTART ================================

This is a feature! Previous versions of IDLE ran your script in the
same process as the IDLE GUI, and this caused a lot of problems. For
instance, it was impossible to run most Python GUI programs from
inside IDLE, and modified modules used by your script wouldn't be
reloaded as expected etc. Restart is your friend! :)

> I only ran the module a few times before this problem started, but I don't think the -----RESTART---- line was appearing at first, but I could be wrong.

If you start IDLE by right-clicking a file in the explorer, and
choose "Edit with IDLE", you will get a single process version of
IDLE, where the restart thing doesn't work. I don't know why they
have done it like that.

If you start IDLE from the Start menu, and open your programs from
within IDLE, you will get the restart behaviour. It seems you have
a real resource problem on your computer if it seems expensive to
start a new process when you run a script, but check with the task
manager to see if there are old python processes hanging around...


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus at thinkware.se



More information about the Tutor mailing list