user396089
user396089

Reputation: 1145

IDLE Python not detecting changes

I am using IDLE to write a few small sized Python programs. There are two class files - node.py (Node Class) and position.py (Position class). I have my main module code in main.py from which I instantiate Node and Position objects.

What I have noticed is that - when I make a change in node.py or position.py, check the modules and then run them using F5 the changes are not reflected back when I run main.py as long as all the files are open in IDLE. I noticed that I have to manually close all the three .py files and then close IDLE, start over again and run main.py to see the changes made in node.py and position.py.

What is the issue here? Are my environment variables not being set correctly? I have searched SO and online but have not found a satisfactory answer.

[Details: I am using IDLE version 2.7.3 in Ubuntu. All the three .py files and the corresponding .pyc byte code files are in the same directory. This directory is also seen in sys.path]

Upvotes: 3

Views: 1754

Answers (2)

n0manarmy
n0manarmy

Reputation: 109

I used Ctrl+F6 as Matthew Plourde suggested. Using Python 3 and IDLE, I would have my test file and my core file open. I would then fix errors reported by my assertions in my test file in my core file but the test file would not see the changes. The only solution I had was closing and reopening which is a pain. Ctrl+F6 did work. I could not find the reload function in Python3.

I retract this statement. With python3, if you run IDLE a "-n" because of lack of admin rights or some other security reason you need to import imp and use imp.reload(function) for IDLE to pickup any changes to other python files you are editing and recalling. Otherwise python does not detect the changes and will not reload the files.

http://docs.python.org/3.0/library/imp.html#imp.reload

Upvotes: 0

user396089
user396089

Reputation: 1145

What was happening is that I needed to use "import node" but I was using "from node import *" from main.py. This was preventing the main.py from linking to the updated node module!

(Sorry for accepting my own answer, but may be someone would also face the same problem later and hence I am uploading the solution)

Upvotes: 3

Related Questions