By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,272 Members | 1,733 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,272 IT Pros & Developers. It's quick & easy.

Problems with Python IDLE

P: n/a
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?

Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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
Jun 27 '08 #2

P: n/a
You probably start idle with the -n option. ...
* ...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...
If you use a shortcut to start IDLE, remove the -n option and you should be
OK.
Thanks! IŽll try that!

Jun 27 '08 #3

P: n/a
On May 27, 3:54*am, Giraffe <kerstin.vilters...@semcon.comwrote:
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 might also look into the reload(module) function, documented here:

http://docs.python.org/lib/built-in-funcs.html

It's made for that sort of thing.

Mike
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.