reimporting a single function in python
function, import, python
Solution
When you do a `from foo import bar`, you are importing the entire module. You are just making a copy of the symbol `bar` in the current namespace. You are not importing just the function.
The `reload` function is not totally reliable (e.g. it will not work for compiled C modules). I would recommend that you exit and restart your interpreter.
Problem
Using python in an interactive mode one imports a module then if the module is changed (a bug fix or something) one can simply use the reload() command. But what if I didn't import the entire module and used the 'from M import f,g' import statement. Is there any way to reimport only g? (I tried removing the function from the parameter table by 'del g' AND delete the .pyc file from the directory. It didn't help. when I reimported the function 'from M import g' the old g was loaded).