VS Code Python Tool Does Multiple Interactive Windows

On Halloween 2018 a developer filed an issue in the GitHub repo for the VS Code Python extension, asking for the ability for users to "spin up multiple 'Python Interactive' windows."

In August 2020, the functionality requested in that issue was officially announced.

"By default, every time you run the 'Python: Create Python Interactive Window' command in the command palette (View > Command Palette ...), it will create a new interactive window in VS Code," said Savannah Ostrowski, program manager, in an Aug. 13 blog post.

"Code cells from Python scripts by default will still be executed in a same interactive window. However, you can now configure the Python extension to run separate files in separate interactive windows. Just open the settings page (File > Preferences > Settings), search for 'interactive window mode' and change the setting value to 'perFile.' Now when you run cells from different files, they will each run on their own separate window."

Multiple Interactive Windows in Action
[Click on image for larger, animated GIF view.] Multiple Interactive Windows in Action (source: Microsoft).

Of course, developers who prefer the single interactive window behavior can opt to retain it with a simple configuration tweak.

The August 2020 update to Python in VS Code also includes support for Pylance, a new Python language server that uses the Language Server Protocol to communicate with VS Code and provide programming "smartness" specific to the popular language, such as autocomplete and smart completions (IntelliSense), error-checking (diagnostics), jump-to-definition, linting and corrections, find all references and so on.

Pylance in Animated Action
[Click on image for larger, animated GIF view.] Pylance in Animated Action (source: Microsoft).

Its marketplace listing says that it provides the following features for Python 3:

  • Docstrings
  • Signature help, with type information
  • Parameter suggestions
  • Code completion
  • Auto-imports (as well as add and remove import code actions)
  • As-you-type reporting of code errors and warnings (diagnostics)
  • Code outline
  • Code navigation
  • Type checking mode
  • Native multi-root workspace support
  • IntelliCode compatibility
  • Jupyter Notebooks compatibility

Pylance, named after a character created by the British Monty Python surreal comedy troupe, can be downloaded from the VS Code Marketplace or installed via a configuration setting.

When we first reported on Pylance on July 1, the Pylance extension was nearing 4,000 installations. Now, at the time of this writing, it's nearing 88,000 installations

The new update to the VS Code Python extension also improves Pylance functionality, specifically related to how it displays signature help when a developer invokes a function with multiple overrides. "You can now navigate between signatures easily while Pylance bolds the appropriate active parameter," Ostrowski said.

A few other highlights called out in today's post include:

  • Cell editing shortcuts for python interactive cells that help make doing data science work directly in Python files even more productive (thanks to @earthastronaut!). (#12414)
  • Added a command to restart the language server. (#3073)
  • Update to the latest version of jedi (0.17.2). This adds support for Python 3.9 and fixes some bugs, but is expected to be the last release to support Python 2.7 and 3.5. (thanks Peter Law). (#13037)
Microsft's Python extension is by far the most popular item in the VS Code Marketplace, with some 23.4 million installations. The company years ago went "all in" on Python for VS Code, to the extent of even hiring the extension's creator, Don Jayamanne.

The full list of changes in the update can be found in the changelog, and developers can learn more about  Python support in Visual Studio Code  in the documentation.

About the Author

David Ramel is an editor and writer for Converge360.

comments powered by Disqus


  • What's Next for ASP.NET Core and Blazor

    Since its inception as an intriguing experiment in leveraging WebAssembly to enable dynamic web development with C#, Blazor has evolved into a mature, fully featured framework. Integral to the ASP.NET Core ecosystem, Blazor offers developers a unique combination of server-side rendering and rich client-side interactivity.

  • Nearest Centroid Classification for Numeric Data Using C#

    Here's a complete end-to-end demo of what Dr. James McCaffrey of Microsoft Research says is arguably the simplest possible classification technique.

  • .NET MAUI in VS Code Goes GA

    Visual Studio Code's .NET MAUI workload, which evolves the former Xamarin.Forms mobile-centric framework by adding support for creating desktop applications, has reached general availability.

  • Visual Studio Devs Quick to Sound Off on Automatic Updates: 'Please No'

    A five-year-old Visual Studio feature request for automatic IDE updates is finally getting enacted by Microsoft amid a lot of initial developer pushback, seemingly misplaced.

  • First Official OpenAI Library for .NET Goes Beta

    Although it seems Microsoft and OpenAI have been deeply intertwined partners for a long time, they are only now getting around to releasing an official OpenAI library for .NET developers, joining existing community libraries.

Subscribe on YouTube