News

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

Featured

  • Xamarin.Forms 5 Preview Ships Ahead of .NET 6 Transition to MAUI

    Microsoft shipped a pre-release version of Xamarin.Forms 5 ahead of a planned transition to MAUI, which will take over beginning with the release of .NET 6 in November 2021.

  • ML.NET Improves Object Detection

    Microsoft improved the object detection capabilities of its ML.NET machine learning framework for .NET developers, adding the ability to train custom models with Model Builder in Visual Studio.

  • More Improvements for VS Code's New Python Language Server

    Microsoft announced more improvements for the new Python language server for Visual Studio Code, Pylance, specializing in rich type information.

  • Death of the Dev Machine?

    Here's a takeaway from this week's Ignite 2020 event: An advanced Azure cloud portends the death of the traditional, high-powered dev machine packed with computing, memory and storage components.

  • COVID-19 Is Ignite 2020's Elephant in the Room: 'Frankly, It Sucks'

    As in all things of our new reality, there was no escaping the drastic changes in routine caused by the COVID-19 pandemic during Microsoft's big Ignite 2020 developer/IT pro conference, this week shifted to an online-only event after drawing tens of thousands of in-person attendees in years past.

Upcoming Events