Changes to imported module ignored

I’m running Mac OS. If I change and save the contents of a file that is being imported as a module, the importing file ignores the changes unless I restart Rhino. This is true even if I also change and save the importing file before running it. What am I doing wrong?

Here’s an example:

imported Module (mod_a.py):

astring = "hello world"

Importing file (mymain.py):

import mod_a as m 

if __name__ == '__main__':    
   print m.astring

I can change the contents of mod_a.py and it has no impact on mymain.py unless i restart Rhino and rerun the script

I think that the modules are only loaded once at startup… It’s that way in Windows as well.

–Mitch

RhinoScript can be reset from Rhino and Python can from the script editor in Windows- I wonder, @stevebaer, if we need a command in Rhino as well for resetting Iron Python ?

-Pascal

This is how python works and is what the reload function is for

http://docs.python.org/2/library/functions.html?highlight=reload#reload

Ah, OK, that should work, I was thinking of a command corresponding to Rhiino’s ResetRhinoScript.

-Pascal