Imported files not reloaded

I have these 2 files:
MyCommand_cmd.py
utils.py

In MyCommand_cmd.py I import something from utils.py.

If I make changes in utils.py I need to quit Rhino and open it again for the changes to take effect. This is quite disturbing for any development flow. Am I missing something? Is there any way I can reset the Python environment in some way, without quitting the application?

Thanks!

you usually use the reload function to handle that without quitting the application. I think it also works with IronPython.

I can confirm:

from imp import reload
reload(utils)

it is a good idea to remove it again when you have finished developing to avoid the reload time.

Thanks Nathan and Graham!

Unfortunately it doesn’t work for object imports:

If a module imports objects from another module using from … import …, calling reload() for the other module does not redefine the objects imported from it — one way around this is to re-execute the from statement, another is to use import and qualified names (module.name) instead.

I ended up refactoring quite a lot of code to fully qualified imports, and then reloading the imported modules during development at the beginning of the commands.

Thanks for your help!