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 file
which will callwriteFile()
and createutils.py
with the code in the editor window - Run
main.py
by clickingRun
- Make a change to
utils.py
and clickWrite file
again, note that when youRun
again, the imported module is unchanged - Click
Watch
which will callwatchModules(['utils'])
and then observe the module has been reloaded when youRun
again - You will still need to click
Write file
again if you make any further changes - To no longer automatically reload the module, you can click
Unwatch
which will callunwatchModules(['utils'])
Loading...
You can find the source code for this example here.