Visual Studio Code is an integrated development environment created by Microsoft for Windows, Linux and macOS. Among its features are debugging, syntax highlighting, smart code completion, snippets, code refactoring and integrated Git. Users can change the theme, keyboard shortcuts, preferences and install extensions that add additional functionality.
Precisely we are going to talk about the extensions you can install for VS. Here is a list of our favorites
A Visual Studio Code extension with rich support for the Python language (for all actively supported versions of the language: >=3.6), including features such as IntelliSense (Pylance), linting, debugging, code navigation, code formatting, refactoring, variable explorer, test explorer, and more!
NOTE: Web support -- e.g., github.dev -- is limited.
The Python extension will automatically install the Pylance and Jupyter extensions to give you the best experience when working with Python files and Jupyter notebooks. However, Pylance is an optional dependency, which means that the Python extension will remain fully functional if it is not installed. You can also uninstall it at the expense of some features if you are using a different language server.
2- Python Indent
How it works
Every time you press the Enter key in a Python context, this extension will parse your Python file down to the location of your cursor, and determine exactly how much to indent the next line (or two in the case of hanging indents) and how much to indent nearby lines.
There are three main cases when determining the correct indent. Review the documentation here: https://github.com/kbrose/vsc-python-indent
3- Python Doctring Generator
- Quickly generate a docstring fragment that can be tabbed.
- Choose from several types of docstring formats.
- Infer parameter types via pep484 type hints, default values and var names.
- Support for args, kwargs, decorators, errors and parameter types.
- Google (default)
- PEP0257 (coming soon)
- The cursor must be on the line directly below the definition to generate a complete auto-populated docstring.
- Press enter after opening the docstring with triple quotes ("""" or ''')
- Keyboard shortcut: ctrl+shift+2 or cmd+shift+2 for mac
- Can be changed in Preferences -> Keyboard shortcuts -> extension.generateDocstring
- Command: Generate Docstring
- Right-click menu: Generate Docstring
4- Python Extended
Run vscode and in a python file, type the name of the method to complete and press tab or enter on selection.
How to install
Open vscode. Press F1, search for "ext install" followed by the extension name, in this case "ext install Python Extended" without the ">". Or if you prefer ">ext install", press enter, search for "Python Extended".
5- Python Preview
- Install a version of Python 3.6 or Python 2.7. Make sure that the location of your Python interpreter is included in your PATH environment variable.
- It is best to install the Python extension for Python Intellisense.
6- AREPL for Python
- First, make sure you have python 3.7 or higher installed.
- Open a python file and click on the cat in the top right bar to open AREPL. You can click the cat again to close it.
- Or run AREPL via the search command: control-shift-p
- or use the shortcuts: control-shift-a (current document) / control-shift-q (new document)
- Real-time evaluation: no need to run - AREPL evaluates your code automatically. You can control this (or even disable it) in the settings.
- Variable display: The final state of your local variables is displayed in a collapsible JSON format.
- Error display: The moment you make a mistake an error is displayed with the stack trace.
- Settings: AREPL offers many settings to suit your user experience. Customize the look and feel, bounce time, python options and much more.
Aldo read: 3 Python Tricks That Will Improve Your Code
7- Python Path
- "Copy Python Path" is accessible from:
- Command line
- Explorer context menu
- Editor context menu
- Editor title context menu
8- Python Test Explorer
How to get started
- Install the extension
- Configure Visual Studio Code to discover your tests (see the Configuration section and the documentation for the test framework of your choice:
- Unittest documentation
- Pytest documentation
- Testplan documentation
- Open the sidebar of the test view
- Execute your tests via the Run icon in the Test Explorer
- Displays a Test Explorer in the test view in the VS Code sidebar with all detected tests and suites and their status
- Convenient error reporting during test detection
- Unittest, Pytest and Testplan debugging
- Displays the log of a failed test when the test is selected in the explorer
- Test rerun when saving tests
- Supports multi-root workspaces
- Supports Unittest, Pytest and Testplan test frameworks and their plugins
9- Python Snippets
- all built-in python snippets and contains at least one example for each method
- all python string snippets contain at least one example for each method
- all python list snippets contain at least one example for each method
- all Python set snippets contain at least one example for each method
- all Python tuple snippets contain at least one example for each method
- all python dictionary snippets contain at least one example for each method
- And it contains many other code snippets (such as if/else, for, while, while/else, try/catch, file process, and
- class snippets and class examples for oop (polymorphism, encapsulation, inheritance, etc.).
If you don't use a method don't worry this extension contains a lot of code examples for each python method.
This extension is not just a code snippet, it will also be useful for learning the python programming language.
You will learn all python methods with a lot of code examples.
For example, if you want to use the string replacement method, you just need to use .replace.
But if you don't know how to use the replace method then use string.replace =>
The Jupyter Extension uses VS code's built-in notebook support. This interface offers a number of advantages to notebook users:
- Out-of-the-box support for VS Code's wide range of basic code editing functions, such as hot output, search and replace, and code folding.
- Editor extensions such as VIM, bracket coloring, linters and many more are available while editing a cell.
- Deep integration with the general workbench and file-based features of VS Code, such as outline view (table of contents), breadcrumbs, and other operations.
- Fast load times for Jupyter notebook (.ipynb) files. Any notebook file is loaded and rendered as quickly as possible, while execution-related operations are initialized behind the scenes.
- Includes a notebook diff tool, which makes it easy to compare and visualize differences between code cells, results and metadata.
- Extensibility beyond what the Jupyter extension provides. Extensions can now add their own specific language or runtime to notebooks, such as the .NET and Gather interactive notebooks.
- Although the Jupyter extension comes with a comprehensive set of the most commonly used renderers for output, the marketplace supports installable custom renderers to make working with your notebooks even more productive. To get started writing your own, check out the VS Code renderer api documentation.
You can also read data science posts in Spanish here.
Also read: Why Decorators In Python Are Pure Genius?