[Tutor] reloading a module
d at davea.name
Thu Oct 4 04:15:20 CEST 2012
On 10/03/2012 09:56 PM, Leo Degon wrote:
> So Ive got code that i import a module to get certain saved variables,
> where i edit the text file that comprises the module to edit those saved
> variable. My problem is I cant reload the module to access those modified
> I was wondering how can i reload or otherwise refresh the module.
> python3 on linux
Python version 3 replaced the reload(xxx) syntax with :
However, there are still lots of caveats, and reasons not to do it.
This doesn't initialize the new module, it doesn't follow the imports
used there, it doesn't tell other modules of the code about this new
version of the module, .... The feature is there for debugging, as far
as I know, and probably shouldn't be used in real code.
If your design is to have these variables' default values to come from
the file, then I'd suggest making it a data file, and not an import.
Then you can literally save and restore those variables flexibly, and
without straining the language's limits.
Alternatively, just restart the process.
More information about the Tutor