Python is a programming language that lets you work more quickly and integrate your systems more effectively. You can learn to use Python and see almost immediate gains in productivity and lower maintenance costs. Visual Studio Code comes packed with everything you need to write great Python code.
Python is a programming language that has been in use since 1991. In this blog post, I will show you the best extension for python which you can install for VSCode.
Python
This is the essential VS Code extension for Python, developed by Microsoft itself. While creating a .py file, VS Code will itself suggest installing this extension. It provides features like analyzing code for potential errors, code formatting, debugging through a debug console, testing with the unit test, pytest, and nose test frameworks. Syntax checking, auto-completion, auto-activation, and switching between different environments are also done by this extension. Moreover, it supports Jupyter Notebooks and therefore is considered as the very basic and important Python extension.
It contains the following features:
- Linting for your code with Pylint or Flake8 support
- Debugging your code within the VS Code editor
- IntelliSense support for auto-completion, code navigation, and formatting.
- Support for Jupyter Notebooks, Pytest, and Unittests
- Easily switch Python environments within the editor
Kite AutoComplete AI Code
Kite is an advancement in the direction of ease of writing code. It is based on AI which enables writing the code quickly in VS Code. When you call a function, Kite will show the arguments required to call it. If you hover on any symbol, it will show a summary regarding it. It provides quick auto-completion and shows only the right thing at a time. It can be used for different programming languages apart from Python such as JavaScript, Go, etc.
Python Preview
This extension is used to preview the Python code in VS Code editor. It is very simple to use and makes debugging easy and fast. It includes graphics and animations to make visualization interesting and easy to understand the status of our code. It brings a visual view to VS Code and is specifically for Python only. It helps to visualize and ensure that what you’re trying to build is actually getting build or not.
Python Snippets
Python Snippets extension is very useful for beginners who are new to this language. It contains built-in snippets for lists, strings, dictionaries, tuple, class, etc with at least one example of each of them. It avoids typing the code again and again by using its snippets directly. Thus, we can say this extension is beginner-friendly and saves a lot of time for Python developers.
AREPL for python
It provides code evaluation in real-time. As you start typing, the code will keep on running which helps to check if the code is right or not during the time of writing itself. If an error is found, it will be reflected in the editor instantly with logs. It can be configured accordingly to fit user experience from the settings. One doesn’t need to run the code, AREPL automatically evaluates it.
Better Comments
Better Comments as the name suggest helps to create comments that are easily understandable. You can easily distinguish between different types of comments like alerts, todos, queries, etc as they are colored differently in order to categorize them. However, you can also change the color setting of the comments. This extension can also be used for languages other than Python.
Python Docstring Generator
It makes it easy to document code in VS Code and follow standard formats. This extension generates docstring for the Python functions, and you can select from different types of docstring formats. This is supported for kwargs, args, errors, and decorators The generated docstring can be formatted as per the user requirement. It provides support for tabbed navigation i.e. when a docstring is generated, you can tab through it to add arguments.
Python Indent
This is a great tool for managing indentation in Python. It automatically gives an adequate number of space or tabs when you hit the enter button for the next line. It is one of the best Python extensions in VS Code that saves a lot of time consumed in fixing indentation errors. The main areas where it helps are between bracket pairs, extending comments, trimming whitespace lines, keyword indentation like if-elif-else, return, etc.
Python Test Explorer
The Python Test Explorer extension allows you to run your Python unittest or Pytest tests with the Test Explorer UI. It shows a Test Explorer in the Test view in VS Code’s sidebar with all the tests that are found. A failed test’s log is displayed when the test is selected in the explorer providing an excellent user interface and debugging capabilities.
Dash
Dash is actually an API Documentation Browser and Code Snippet Manager for macOS. This is a very important extension when you need to refer to the official documentation of Python. If you need to get more information about Classes, Functions, or Types you highlight the code, then press ctrl + h to access the official documentation offline. The benefit of having your docs offline is that you don’t need to have internet access to start coding and looking up references which allows you to focus more on the coding part.
This is absolutely a necessary extension when you need to refer to the official Python documentation while you’re coding.
Dash is an API Documentation Browser and Code Snippet Manager. Dash instantly searches offline documentation sets for 200+ APIs, 100+ cheat sheets, and more. You can even generate your own docsets or request docsets to be included.
This VS Code extension allows you to invoke Dash from the editor. So if you need to get more information about Classes, Functions, or Types you highlight the code and press ctrl + h
to access the official documentation offline. If you compare this to going in the browser and visiting the official documentation website to search for the API, it goes a lot quicker doing it offline.
The benefit of having your docs offline is that you don’t need to have internet access in order to start coding and looking up references. Finding pages that are stored locally can be accessed way quicker than trying to google and needing to find the specific thing you’re looking for. These benefits boost your productivity and allow you to focus more on the coding part.
Git Lens
This extension has at the time of writing already has more than 5 million downloads! This extension is not only a game-changer it makes sure you use Git in other ways you normally wouldn’t have used it within your CLI. As the creator of this plugin states:
GitLens supercharges the Git capabilities built into Visual Studio Code. It helps you to visualize code authorship at a glance via Git blame annotations and code lens, seamlessly navigate and explore Git repositories, gain valuable insights via powerful comparison commands, and so much more.
Their feature list is very comprehensive, if you want to see what it can do, please check out their readme on the VS Code marketplace. I’ll share 2 of my favorite features.
Git blame shows author metadata attached to specific committed lines in a file. This is handy if you work with multiple people on the same files and see who modified a piece of code. But instead of running git blame -L 1,5 in your terminal to see who did a modification on lines 1 to 5, you immediately see the line modification in VS Code using Git Lens.
The details hover feature allows you to see git blame on the current line of code when you hover your mouse over it. Second, to that, it provides a quick access command bar that allows you to change to the previous commit revision, open changes, do diffs, and showing commit details.
Pyright
Pyright is an incredibly fast static type checker and code validator. If you manage a large codebase in Python a linting tool like Pylint could be quite heavy. This extension includes the following features:
- Intelligent type completion of keywords, symbols and import names
- Automatically insert import statements for type completions when necessary
- Show docstrings and type information when you hover over symbols
- Quickly find the location of the symbol’s definition when you click on the hover over the symbols.
- Quickly find or rename all references to a symbol within a codebase
- Automatically reorder imports in your code according to PEP8 rules.
- Third-party libraries have support for type stub generation
Indenticator
Next up we have Indenticator. This VS Code extension allows you to set up your preferred indentation for each of your programming languages separately. The benefit of having this enabled is that you can easily see where for loops or if statements end within your code.
Indent rainbow
Indent rainbow adds colors to your indents which makes readability even better, especially in a dark background like in VS Code. Combine this with Indenticator to improve the reading fluency of your code. You have the option to customize the indent colors to your liking.
Conclusion
Python is one of the most popular programming languages out there. Visual Studio Code also has become more and more popular these days, especially among Python developers.