473,382 Members | 1,512 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,382 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 2877
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.