From the course: Visual Studio Code for Python Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Formatting Python code

Formatting Python code

From the course: Visual Studio Code for Python Developers

Start my 1-month free trial

Formatting Python code

- [Instructor] The Python extension for VS Code provides support for automatic code formatting. Formatting makes your code easier to read and comprehend and this is particularly important in a language like Python where things like indentation and white space affect the code itself. There are a few different ways to automatically apply formatting to your code. VS Code supports automatic code formatting using AutoPep8 which is the default, along with Black and Yapf. So for the sake of simplicity, I'm just going to demonstrate AutoPep8. Now if you're not familiar with PEP or PEP 8, you can learn more about it at this link on the Python website. It's essentially a collection of formatting rules intended to make Python code easier to read. The AutoPep8 library can be used to implement these formatting rules automatically within VS Code. You'll need to use the Python pip tool in order to install this library. If you don't already have pip installed, you'll need to get it and that's beyond…

Contents