473,287 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Problems with Python IDLE

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
3 2872
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Aubrey Hutchison | last post by:
Using Python 2,3,2 with idle for developing programs about 200 lines long. - Problem is not common to any specific program. Program are rather simple with no trick programming. Usually no classes...
4
by: Colin J. Williams | last post by:
PythonWin has been my favourite IDE for quite a while. When one right clicks on a .py file in the Windows Explorer, among the options are Open and Edit. The former is the default and executes...
2
by: Irmen de Jong | last post by:
Hello I haven't received any responses on my original posting, and it could very well be that it never made it to the newsgroup (because I can't find it back on my news server here). So I'm...
1
by: Bennie Tilma | last post by:
I'm having trouble with opening the IDLE and running programs. Every time I try to open it, it says: 1. Socket error: Connection refused 2. IDLE's subprocess didn't make connection. Either IDLE...
14
by: John Salerno | last post by:
Here's an exercise I was doing to guess a number from 1-100. Just for fun (ha ha) I decided to add some error checking too, and now when I run it, the DOS prompt flashes real quick and disappears....
4
by: renguy | last post by:
I am interested in making some changes and additions to the Python environment (Python and IDLE). I have the source code and can build the source, but what I want to know is what are the "main"...
3
by: 7stud | last post by:
Hi, In the IDLE, I can't get most shortcut keys that are listed next to the menu items to work. For instance, under the Format menu item only the shortcuts for "indent region" and "undent...
5
by: Sven Siegmund | last post by:
Hello, I am testing Python 3.0a5's handling of unicode strings. Since SPE is not yet for Python 3.0, I have begun to write in IDLE 3.0a5. I have a source code which IDLE 3.0a5 cannot parse,...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.