Question

when using idle, I know you can reload a module if it's changed like this:

import foo
reload(foo)

if I only import part of a module, is there a way to reload it in a similar matter?

from foo import bar
Was it helpful?

Solution

No, reload has to re-run the whole module.

Note that reload is confusing and does not have the ability to be consistent. It's much better to restart the interpreter.

OTHER TIPS

No. You'll have to import foo, then reload(foo), after all.

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

It says:

"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."

But the statements is not very clear.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top