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

Scott David Daniels scott.daniels at acm.org
Sat Dec 3 00:07:29 EST 2005


Christophe wrote:
> infidel a écrit :
>>> I'm using the Windows version of Python and IDLE. When I debug my .py
>>> file, my modification to the .py file does not seem to take effect
>>> unless I restart IDLE. Saving the file and re-importing it doesn't help
>>> either. Where's the problem?
>>
>> "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.
You are mistaken if you think this is an Idle behavior; it is a Python
behavior that speeds the execution of large systems.

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list