Pocket-E

Quick Notes

Jul18

Simple Module Reload in Python

Written by // Joel Categories // Quick Notes

So I'm playing in the Python shell and do something like:

 
import controller.util
 

or

 
from controller.util import something
 

Then I see I did something silly in my controller.util code and my function doesn't work as expected. I update the code and want to retest without getting out of my Python shell.

 
import sys, imp
mod = imp.reload(sys.modules['controller.util'])
mod.something('it works')
 

That's all folks