Visual Studio Code for Python Developers Transcripts
Chapter: Editing Python Code with VS Code
Lecture: What is the Python Extension?

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Now, I mentioned the Python extension, and before we go installing it in Visual Studio Code for use in the project, let's get an understanding of what it is and what it makes possible.
0:10 Now, if you go over to the Visual Studio Code website, code.visualstudio.com, and you click on API, and then Language Extensions, let's get an overview of that.
0:21 The Python extension is what's called a language extension. It's a type of extension that will give smart editing features for your particular programming language through this type of an extension.
0:32 So, VS Code is not providing built-in language support for Python, per se, to the degree that you would expect or want out of an editor or an interactive development environment.
0:43 The way they provide that is through extensions. It's extensibility. In this case, the Python extension, let's go take a look at what that is.
0:51 So, the Python extension is in the Marketplace.
0:52 The Python extension in the Marketplace, which you can go through on the website or directly through the extensions view within Visual Studio Code, and you search for Python, you'll want to look for the one that's from Microsoft directly.
1:04 It has that little blue checkmark there.
1:06 And what this ends up doing is it creates that rich experience for you by including features such as IntelliSense through PyLance, linting, debugging, code navigation, code formatting, refactoring, Variable Explorer,
1:21 text, and so on. And you can also add a lot of other features like the VSCode extension, which is a great extension for your own computer.
1:22 I mean, I don't know how you can have any more because that was a lot in itself and a mouthful to say. But that's what the extension does.
1:29 It creates that rich experience.
1:31 It allows you to opt in because it doesn't know whether you as a developer are going to be working with Python or some other languages.
1:37 And so that's why VS Code takes this approach so that you can enhance the experience there based on the type of projects you're working with and the programming language you're using.
1:47 Now, what's interesting about this extension is it used to be actually a bunch of separate extensions.
1:51 It used to be a bunch of extensions that you would put together and install separately.
1:54 But now Microsoft has opted to go with a more bundled approach with a lot of things baked into it.
1:59 And because of that, you're going to have some options to set up things with it.
2:04 But in particular, I want to go over the more detailed features that it provides, which is IntelliSense.
2:09 IntelliSense allows you to essentially have autocomplete. You can think of them as kind of interchangeably, but don't quote me on that.
2:15 But essentially, if you have functions that you want to use or modules you're trying to import, it can give you...
2:21 It can give you smart suggestions as you're typing that out and then help you if you hit tab or enter to autocomplete that suggestion.
2:28 And we'll see an example of that shortly. In addition to that, there's linting.
2:31 You can choose whatever linting approach or tool you'd like to use, like PyLint or Flake and any other ones that are out there that have an extension within Visual Studio Code.
2:40 When it comes to code formatting, which is super important because you want to have consistent formatting on your projects,
2:45 especially if you're working on a team with other developers, you need to rely upon a tool to... keep that consistent throughout your project.
2:53 So something like Black or AutoPep, those are your options that you can use in conjunction with the Python extension.
3:00 And then debugging, testing, and all these other things that we'll get into in later videos,
3:05 such as the testing and debugging that Cecil will cover in a later chapter.
3:09 And then last but not least, I want to mention at least, is the refactoring Python code, which is super important when you're editing code.
3:16 You want to be able to quickly refactor things. Maybe you're renaming a variable that's used throughout a file. Or other files.
3:22 You want that support within Visual Studio Code, and that comes through the Python extension.
3:27 And a little bit more, if you wanted to get componentized support to enable additional refactoring,
3:32 such as import sorting, you get that through extensions like Isort or Ruff.
3:36 And that, in a nutshell, is the Python extension, which is a language-based extension for Visual Studio Code.
3:44 In the next video, we're going to get into installing it, setting it up, and seeing how the experience is different from the default experience.
3:50 in Visual Studio Code.


Talk Python's Mastodon Michael Kennedy's Mastodon