skip to Main Content

I really like the debug console feature in VScode, it makes it a lot easier for me to do Python writing. How do I get it to stay on? Is it possible to write launch.json so that the code runs without closing the run afterwards?

I can use ‘time.sleep()’ to continue this console on.
Can I edit the’launch.json’?
What are other ways?

2

Answers


  1. It’s not possible to keep the debug console open after the script ends, because the memory is released back to the operating system.

    Edit: as @nigh_anxiety mentioned, setting a breakpoint at the end of the script is probably a more elegant solution.


    Old Answer:

    Instead, you could wait for user input before exiting, with a line like

    input('press enter to quit')
    

    at the end of your file.

    Login or Signup to reply.
  2. The interactive window should work for you. Open an interactive window with the command Jupyter: Create Interactive Window

    enter image description here

    Or right-click on the code editor interface and select Run Current File in Python Interactive Window.

    enter image description here

    In this window, you can directly run the code file or write the code and then shift+enter to run.

    More details can be found in the documentation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search