Custom Modules
By default, Python modules are cached. If you intend to make changes to an imported module, it needs to be watched and reloaded.
Create a module using the file system APIs or write the file using Python, examples here.
Then call watchModules() to automatically reload the module before running code. For more info, see the API reference docs.
The following example shows this in action. To try it out:
- Click
Write filewhich will callwriteFile()and createutils.pywith the code in the editor window - Run
main.pyby clickingRun - Make a change to
utils.pyand clickWrite fileagain, note that when youRunagain, the imported module is unchanged - Click
Watchwhich will callwatchModules(['utils'])and then observe the module has been reloaded when youRunagain - You will still need to click
Write fileagain if you make any further changes - To no longer automatically reload the module, you can click
Unwatchwhich will callunwatchModules(['utils'])
Loading...
You can find the source code for this example here.