Save over 40% when you secure your tickets today to TNW Conference 💥 Prices will increase on November 22 →

This article was published on January 12, 2021

7 essential VS Code extensions for Python developers in 2021


7 essential VS Code extensions for Python developers in 2021

We listed the best VS extensions for JS developers. Now it’s time we do so for the Python community.

I’m a PyCharm user and I won’t probably be changing editors anytime soon, but with all the hype around VS Code and so many people over Reddit and Twitter suggesting me the switch, I had to try it.

My VS Code experience was amazing, and even though my heart still belongs to PyCharm, VS Code is a fantastic product, I can 100% recommend. It’s customizable, fast, and with a ton of extensions that make it very powerful.

Today we will cover the top VS Code extensions for Python for 2021.

Python

Python

VS Code supports code highlighting for Python without this extension. However, if you will be working with Python, you should install this extension. It is developed by Microsoft itself, the same creator of VS Code. It’s so essential for Python developers’ productivity that VS Code will automatically suggest that you install it right after opening your first .py file.

[Read: Meet the 4 scale-ups using data to save the planet]

But why do I need it if I already have syntax highlighting? This extension is a powerhouse of functionality when it comes to working with Python. It provides functionalities like:

  • IntelliSense: Edit your code with auto-completion, code navigation, syntax checking, and more
  • Linting: Get additional code analysis with Pylint, Flake8, and more
  • Code formatting: Format your code with black, autopep or yapf
  • Debugging: Debug your Python scripts, web apps, remote or multi-threaded processes
  • Testing: Run and debug tests through the Test Explorer with unittest, pytest, or nose
  • Jupyter Notebooks: Create and edit Jupyter Notebooks, add and run code cells, render plots, visualize variables through the variable explorer, visualize dataframes with the data viewer, and more
  • Environments: Automatically activate and switch between virtualenv, venv, pipenv, conda, and pyenv environments
  • Refactoring: Restructure your Python code with variable extraction, method extraction, and import sorting

Look at it in action:

Demo of Python extension

Download Python

Python Snippets

Python Snippets

Python Snippets is an extension full of in-built snippets packs developed by Ferhat Yalçın. This extension is great for any developer but especially for beginners in Python. It contains numerous in-built snippets such as string, list, sets, tuple, dictionary, class, and much more. Another advantage of using this plugin is that it also provides at least one example of each snippet, making it awesome while learning Python.

Download Python Snippets

Python Docstring Generator

Python Docstring Generator

We already talked about the importance of documentation and how much I love documenting the code, but we all know it can be a frustrating task. Python Docstring Generator diminishes the endeavor of developers by auto-creating docstrings.

The best thing about this extension is that it follows all standard formats of docstring (including Google, docBlockr, Numpy, Sphinx, and PEP0257 is coming soon), and that is cool. Moreover, this docstring generator supports args, kwargs, decorators, errors, and parameter types with multiline commenting features.

Just see it in action and be amazed:

Demo of Python Docstring Generator

Download Python Docstring Generator

Python Test Explorer for Visual Studio Code

Python Test Explorer

The Python Test Explorer extension allows you to run your Python unittest or Pytest tests with the Test Explorer UI. This small and handy tool will enable you to test your code from VS Code’s comfort with an excellent user interface and debugging capabilities.

We know the importance of unit testing so having a tool like this on your IDE or code editor is a must-have.

Demo of Python Test Explorer

Download Python Test Explorer

Python Preview

Python Preview

Python Preview is an extension that adds visual debugging to your Python code. It transforms debugging code into an interactive session with animations and graphic elements to represent your application status. You just have to see it:

Demo of Python Preview

Download Python Preview

Python Type Hint

Python Type Hint

Yes, Python has something like Types, and yes, it is awesome. Think of Type Hints for Python as TypeScript is for JavaScript. It’s a game-changer that I hope we start seeing more often in tutorials and applications. Python Type Hint provides type hint completion items for built-in types, estimated types, and the typing module. Moreover, it can search for Python files in the workspace for type estimation purposes.

Demo of Python Type Hint

Download Python Type Hint

Jupyter

Jupyter

Jupyter is one of my favorite VS Code extensions. Yes, it is what you are thinking. It’s Jupyter Notebooks directly in VS Code. As someone who’s always working with Jupyter Notebooks, this extension was beneficial, and I believe there’s still a lot I have to explore about it.

Integration with Jupyter Notebooks is one of my favorite features of PyCharm, though to be fair, I love the PyCharm integration more than I do the VS Code integration. With that said, Jupyter for VS Code is for free, while PyCharm Jupyter Notebook integration is only available in the pro version.

Download Jupyter

Conclusion

As I mentioned in the JS version of this post, VS Code positively surprised me. It’s a solid tool for coding fast, flexible, and with expanding features through extensions.

Interestingly, all these extensions I listed here today are some of my favorite features in PyCharm, but free of cost and with a fantastic user experience.

Still, details about the editor bug me, and so, my editor of choice is PyCharm. However, with quality extensions like this, I see how it can get hard to justify paying for it.

This article was originally published on Live Code Stream by Juan Cruz Martinez (twitter: @bajcmartinez), founder and publisher of Live Code Stream, entrepreneur, developer, author, speaker, and doer of things.

Live Code Stream is also available as a free weekly newsletter. Sign up for updates on everything related to programming, AI, and computer science in general.

Get the TNW newsletter

Get the most important tech news in your inbox each week.

Also tagged with