4

I am brand new to VSCode with Python. Is it possible to write to the tab DEBUG CONSOLE (only) from Python code? I have Googled but found nothing on this.

The debugger does this internally, e.g. on a breakpoint set to Log Message. For the moment, if I use print() that does go to DEBUG CONSOLE, but it also goes to TERMINAL tab, which I'd rather it did not. The launch.json has "console": "integratedTerminal" if that is relevant.

JonBrave
  • 4,045
  • 3
  • 38
  • 115
  • If you are interested in using this setting globally (it is per-debug-configuration currently), you may want to upvote this feature request: https://github.com/microsoft/vscode-python/issues/18353 – bers Jan 25 '22 at 17:48

1 Answers1

5

You can set "console": "internalConsole" to have output go to the debug console.

Brett Cannon
  • 14,438
  • 3
  • 45
  • 40
  • Thank you. Yes, this causes output *only* to **DEBUG CONSOLE**! It wasn't quite what I wanted --- I wanted a call from Python code which achieved that regardless of `"console"` setting, I might want `integratedTerminal` for elsewhere in code. I don't understand from the docs why `"integratedTerminal"` causes output to *both* **DEBUG CONSOLE** *and* **TERMINAL** tabs, but there you are. Unless you respond further, I will mark yours as the Accepted Solution soon, thanks! – JonBrave Nov 28 '19 at 09:39
  • 1
    @JonBrave what you're after isn't currently supported. You can file a feature request at github.com/microsoft/ptvsd if you would like that feature. – Brett Cannon Nov 29 '19 at 19:33
  • Ah, that would explain why it currently doesn't work that way! Thanks. I'll mark this as the effective solution. – JonBrave Nov 29 '19 at 22:23
  • That option does or might have this issue re input https://stackoverflow.com/questions/73993577/in-vs-code-when-running-a-python-program-via-the-debugger-with-internalconsole – barlop Oct 08 '22 at 00:30