February 2006
Intermediate to advanced
648 pages
14h 53m
English
The built-in function reload() can be used to reload and execute the code contained within a module previously loaded with import. It accepts a module object as a single argument. For example:
import foo ... some code ... reload(foo) # Reloads foo
All operations involving the module after the execution of reload() will utilize the newly loaded code. However, reload() doesn’t retroactively update objects created using the old module. Therefore, it’s possible for references to coexist for objects in both the old and new versions of a module. Furthermore, compiled extensions written in C or C++ cannot be reloaded using reload().
As a general rule, avoid module reloading except during debugging and development.
Read now
Unlock full access