Why my modification of source file doesn't take effect whendebugging?

Christophe chris.cavalaria at free.fr
Mon Dec 5 14:33:54 CET 2005

Fredrik Lundh a écrit :
> Christophe wrote:
>>>"import" only reads the file the first time it's called.  Every import
>>>call after that looks up the module in memory.  This is to prevent
>>>circular dependencies between modules from creating infinite loops.
>>>You need to use the reload() function:
>>As a matter of fact, it would help a lot if that stupid behaviour of
>>Idle was dropped. I'm sure I'm not the only one who lost lots of time
>>because of that bug. Yes I call it a bug.
> in the version of IDLE I have on this machine, if I modify my script and
> run it again (using F5), things work exactly as expected.
> if I modify my script and import it into a clean shell (ctrl-F6), things work
> exactly as expected.
> the only way to get the "buggy" behaviour you're describing is to attempt
> to run your program by importing it as a module more than once into an
> existing python shell process.  in that case, import works in the same way
> as it always works.
> after all, "import" isn't designed to run programs, it's designed to import
> modules.  if you want to run stuff in IDLE, why not just use the "run"
> command ?

F5 is designed to run the current open file. Sane people won't assume 
that pressing twice the F5 key will yield different. Sane people will 
assume that when you edit file1.py and press F5, it reparses the file, 
but when you edit file2.py and press F5 with file1.py it won't work. Why 
make it different ? Why make is so that I have to select the shell 
window, press CTRL+F6, select the file1.py and press F5 just so that it 
works as expected ?

Idle is ok when you edit a single .py file. As soon as I need to edit 2 
.py files with one using the other, I'm glad I have other editors which 
spanw a clean shell each time I run the current file.

More information about the Python-list mailing list