Quantcast
Channel: Semi-Legitimate Feed
Viewing all articles
Browse latest Browse all 10

Simple Module Reload in Python

$
0
0

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

Author

Joel

Viewing all articles
Browse latest Browse all 10

Trending Articles