Problems with Python IDLE

Peter Otten __peter__ at web.de
Tue May 27 06:01:31 EDT 2008


Giraffe wrote:

> I have the followong class in a file:
> --------------------------------------------
> class someClass:
>    def __init__ (self):
>       self.someVar = 10
> 
>    def getSomeVar (self):
>       return self.someVar
> --------------------------------------------
> 
> In another file a do the following:
> --------------------------------------------
> tmp = someClass ()
> tmp.getSomeVar ()
> --------------------------------------------
> 
> I run the second file in the IDLE environment and everything seems to
> be working fine until I start to modify in the first file:
> --------------------------------------------
> class someClass:
>    def __init__ (self):
>       self.someVar = 10
> 
>    def getSomeVar (self):
>       print "Modified class!"
>       return self.someVar
> -------------------------------------------
> 
> When I now try to run the second file in the IDLE environment again, I
> DO NOT get the newly added printout. I have saved and compiled (run)
> both files but there is still no change. What have I missed?

You probably start idle with the -n option. If so, IDLE shows something like

IDLE 1.2.1      ==== No Subprocess ====

in its shell. Here's what IDLE's help says about that:

"""
Running without a subprocess:

        If IDLE is started with the -n command line switch it will run in a
        single process and will not create the subprocess which runs the RPC
        Python execution server.  This can be useful if Python cannot create
        the subprocess or the RPC socket interface on your platform.  However,
        in this mode user code is not isolated from IDLE itself.  Also, the
        environment is not restarted when Run/Run Module (F5) is selected.  If
        your code has been modified, you must reload() the affected modules and
        re-import any specific items (e.g. from foo import baz) if the changes
        are to take effect.  For these reasons, it is preferable to run IDLE
        with the default subprocess if at all possible.
"""

If you use a shortcut to start IDLE, remove the -n option and you should be
OK.

Peter



More information about the Python-list mailing list