473,672 Members | 3,354 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IDLE confusion

Hi, I'm trying to use IDLE to develop My First Python App and my head
hurts...

I've a file called spalvi.py with this in it:
from Test import *
firstTest("Mike ")

And a file called Test.py with this in it:
def firstTest(name) :
print "Yo",name

I open spalvi.py with IDLE and Run it. It says "Yo Mike".
I use the File menu to open Test.py and change the message from "Yo" to
"Hi".
I Run it again.... it still says "Yo Mike" :-(
I close everything down, open spalvi.py with IDLE and Run it again. It
says "Hi Mike".

So I'm obviously not using IDLE in the "right" way. But what *is* the
"right" way, when you're trying to develop using several source files?

John

May 16 '06 #1
6 1787
MrBlueSky wrote:
Hi, I'm trying to use IDLE to develop My First Python App and my head
hurts...

I've a file called spalvi.py with this in it:
from Test import *
firstTest("Mike ")

And a file called Test.py with this in it:
def firstTest(name) :
print "Yo",name

I open spalvi.py with IDLE and Run it. It says "Yo Mike".
I use the File menu to open Test.py and change the message from "Yo" to
"Hi".
I Run it again.... it still says "Yo Mike" :-(
I close everything down, open spalvi.py with IDLE and Run it again. It
says "Hi Mike".

So I'm obviously not using IDLE in the "right" way. But what *is* the
"right" way, when you're trying to develop using several source files?

John

You need some deeper understanding of what import does and what happens
when you import again (after the library files have changed).
Try in the IDLE menu [Shell] "Restart Shell" (Ctrl+F6) each time you
have changed something in your files - this "resets" anything previously
imported, which stays the same way otherwise.

Claudio
May 16 '06 #2
Claudio Grondi a écrit :
MrBlueSky wrote:
Hi, I'm trying to use IDLE to develop My First Python App and my head
hurts...

I've a file called spalvi.py with this in it:
from Test import *
firstTest("Mike ")

And a file called Test.py with this in it:
def firstTest(name) :
print "Yo",name

I open spalvi.py with IDLE and Run it. It says "Yo Mike".
I use the File menu to open Test.py and change the message from "Yo" to
"Hi".
I Run it again.... it still says "Yo Mike" :-(
I close everything down, open spalvi.py with IDLE and Run it again. It
says "Hi Mike".

So I'm obviously not using IDLE in the "right" way. But what *is* the
"right" way, when you're trying to develop using several source files?

John

You need some deeper understanding of what import does and what happens
when you import again (after the library files have changed).
Try in the IDLE menu [Shell] "Restart Shell" (Ctrl+F6) each time you
have changed something in your files - this "resets" anything previously
imported, which stays the same way otherwise.

Claudio


And I though that "bug" was fixed already :) Try to use something else
than IDLE for your code editing. Use Scite for example.

http://www.scintilla.org/SciTE.html
May 16 '06 #3

"Christophe " <ch************ *@free.fr> wrote in message
news:44******** **************@ news.free.fr...
Try in the IDLE menu [Shell] "Restart Shell" (Ctrl+F6) each time you
have changed something in your files - this "resets" anything previously
imported, which stays the same way otherwise.


And I though that "bug" was fixed already :)

On my system, the current 2.4.3 version of Python+IDLE *does* auto restart
with each run (F5). So either the OP is using a much older version (did
not specify) or the respondant mis-diagnosed the problem.

tjr

May 16 '06 #4
This isn't really an IDLE issue, it's a Python feature which needs to
be understood.

In Python, once you've imported a module once, importing it again is
ignored. This works fine under the assumption that modules don't change
during a single Python session. However, when you're developing a
module this isn't true, and a workaround for this mechanism is needed.
The safest way to go is to start a new Python session.

In the IDLE interpreter ("Shell" window) you can do this from the Shell
menu. Running a module from an IDLE editor window (Run->Run Module)
will also restart the interpreter.

Notice, however, that these will only work if IDLE has a sub-process
for the interpreter! If not, the Shell menu won't exist, and Run Module
won't restart the interpreter.

On Windows, opening IDLE by right-clicking a file and choosing 'Edit
with IDLE' will cause it to open without a subprocess.

If you change a module and want to use the newer version in the same
Python session, use the built-in 'reload' function:

import Test
reload(Test)

Notice that if you use the 'from <module> import ...' syntax, you need
to import the module itself (i.e. import <module>) before you can
reload it.

I advise to use this with care, as things can get quite confusing after
a few reloads...

May 17 '06 #5
Terry Reedy a écrit :
"Christophe " <ch************ *@free.fr> wrote in message
news:44******** **************@ news.free.fr...
Try in the IDLE menu [Shell] "Restart Shell" (Ctrl+F6) each time you
have changed something in your files - this "resets" anything previously
imported, which stays the same way otherwise.

And I though that "bug" was fixed already :)

On my system, the current 2.4.3 version of Python+IDLE *does* auto restart
with each run (F5). So either the OP is using a much older version (did
not specify) or the respondant mis-diagnosed the problem.


I was looking at some idlefork info not long ago and I found something
which might get those different behaviours with a recent version of idle
: if idle cannot open it's RPC socket, it'll execute all python code in
it's own interpreter. There's an option for that in fact.
May 17 '06 #6
Christophe wrote:
Terry Reedy a écrit :
"Christophe " <ch************ *@free.fr> wrote in message
news:44******** **************@ news.free.fr...
Try in the IDLE menu [Shell] "Restart Shell" (Ctrl+F6) each time you
have changed something in your files - this "resets" anything previously
imported, which stays the same way otherwise.

And I though that "bug" was fixed already :)

On my system, the current 2.4.3 version of Python+IDLE *does* auto
restart with each run (F5). So either the OP is using a much older
version (did not specify) or the respondant mis-diagnosed the problem.


I was looking at some idlefork info not long ago and I found something
which might get those different behaviours with a recent version of idle
: if idle cannot open it's RPC socket, it'll execute all python code in
it's own interpreter. There's an option for that in fact.

The option (for those playing along) is '-n'
So:
Windows: command is: \python24\Lib\i dlelib\idle.pyw -n
OS-X: command is: pythonw ?/python24/Lib/idlelib/idle.pyw -n
Linux & such: python ?/python24/Lib/idlelib/idle.pyw -n
(I think these don't
distinguish python & pythonw)

It is useful if you are having some socket-to-self issues typically
caused by over-conservative firewall settings, because no socket
is allocated for communication.

It is also useful for experimenting with Tkinter, because a Tkinter
display loop is already running, so you can see the effects of your
Tkinter commands as they are entered.

--Scott David Daniels
sc***********@a cm.org
May 17 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
12918
by: Kerry Neilson | last post by:
For the past couple of months, Idle won't start when I invoke it. I am at a complete loss for why this is. When this happens, they python command line still starts, and python works fine otherwise. Most interesting to me is that a reboot won't fix the problem. But if I just try it again sometime later it will work. Anyone have any ideas? I'm running python 2.3 on windows 2000 professional.
1
5471
by: Moosebumps | last post by:
So say I am working on two separate .py files in IDLE that are part of the same program. Does anyone have problems where when you modify one file, and then run the other, the changes you made in the first aren't updated? I usually just close all the files, and restart IDLE, but this is a pain. Maybe because I always use right click -> edit with IDLE (on Windows). That starts up a separate Python Shell too, which I always close. MB
1
6724
by: dbrown2 | last post by:
I typically use IDLE for editing and debug. On Windows at least, IDLE and the standard turtle graphics module do not mix. I think both use Tkinter. For now I use IPython and Jedit when using the turtle module but it's not a great solution for me. Is there any known work-around to use turtle with IDLE? If not is there a planned fix for the problem. I find turtle is a convenient way to do simple graphics without having to install...
8
3768
by: Jonathan Polley | last post by:
I have one account on a WindowsXP machine that refuses to run IDLE (or any other python script that uses Tk). Other people can login to that PC and IDLE runs just fine, so it is not an installation issue. When the person who has the problem logs into another PC the problem follows them. Any ideas as to what might me wrong? This is the traceback from IDLE: C:\Python20\Tools\idle>..\..\python.exe idle.py Traceback (most recent call...
19
46632
by: Frank Rizzo | last post by:
I want to log the user out when there has been a period of inactivity in the application. The key here is inactivity of the application, not the system. I know that you can retrieve the inactivity of the system via GetLastInputInfo. That's not what I want - I want inactivity of the application. Thanks.
7
1983
by: iwdu15 | last post by:
how can i tell if my system has gone idle? then how can i execute a command accordingly? thnks
0
1449
by: Stefan Felkel | last post by:
hi! i have searched a lot in these pgsql-groups and on the internet, but found no really helpful information for my problem. the famous error >> database "xyz" is being accessed by other users is my problem.
1
2232
by: cbielins | last post by:
DB2v8.x - AIX64 what status is considered 'idle' by DB2? Connect Completed UOW Waiting I would think statuses like this would be considered 'idle' and thus forced off if you have a written rule within the config file.
5
2788
by: Russ P. | last post by:
I've been programming in python for a few years using XEmacs on Solaris and Linux. I've been thinking about trying IDLE for a long time, but either it wasn't available on my system or I procrastinated. I finally have it available, and I gave it a try. I immediately encountered a basic problem for which I could not find a solution in the intro docs. I want to run a script in one directory that reads input from a file in another directory....
0
8504
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8419
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8945
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5720
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4242
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4439
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2837
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1837
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.