Path: blob/main/doc/tutorials/intermediate/develop_editor.md
2012 views
Develop in an Editor
In this section you will learn more advances techniques to develop efficiently in an editor:
Resetting the cache with
pn.state.clear_caches()
orsome_cached_func.clear()
.Debug with Pdb by inserting a
breakpoint()
:::{note} This guide builds upon the Develop in an Editor (beginner) tutorial. :::
:::{note} Some of the features demonstrated in this guide might require special configuration of your editor. For configuration we refer you to the Resources section below and general resources on the web. :::
Resetting the Cache
When developing with the --dev
option and utilizing caching, you may need to reset the cache. You have the option to clear either the entire cache or just the cache for a specific function.
Execute the code below:
To reset the cache, uncomment and use either pn.state.clear_caches()
for the entire cache or get_data.clear()
for the specific function's cache. Below is a video demonstrating this process:
Debug your App with Pdb
A simple way to debug your apps that works in any editor is to insert a breakpoint()
.
Copy the code below into a file named app.py
.
Serve the app with panel serve app.py --dev
.
Open http://localhost:5006/app in a browser.
The app will look something like
Click the Click Me
Button.
Your terminal will look something like
Write event
in the terminal. Press ENTER
.
It should look like
Write help
and press ENTER
for more info. It will look like
Write c
and press ENTER
to continue running the code and server.
:::{note} For more about debugging with Pdb and breakpoint
please check out the PDB Documentation. :::
:::{note} For integrated debugging in your editor, please refer to the Resources section below and general resources on the web. :::
Recap
You have learned to
Reset the cache with
pn.state.clear_caches()
orsome_cached_func.clear()
.Debug with Pdb by inserting a
breakpoint()