Locked learning resources

You must own this product to watch this lesson.

Locked learning resources

You must own this product to watch this lesson.

Overview

00:00 Hey! And welcome to my video lessons on setting up a productive Python development environment using the Sublime Text editor. In this course, I’m going to show you how to set up a Python development environment from scratch, starting with a new Windows 10 installation.

00:13 We’re going to install Python, Git, and Sublime Text completely from scratch. We’re going to end up with the setup that I’m demoing to you now. I just want to show you some of the coolest features in the setup before we dive in into the actual lessons, where you’ll learn how to set everything up.

00:30 The first thing you can see here is that I’ve applied a couple of visual tweaks to my Sublime Text setup. For example, I’m using a custom dark color scheme here, which is just a lot nicer when you’re staring at your screen for a long time, working with your code for a long time. It just makes it easier to focus.

00:45 Also, it gets rid of this distracting white area here in the default sidebar, and it adds these nice and colored icons for file types. I’ve also integrated Python code linting into my setup.

00:57 That way, I can get instant feedback on any code that I write. For example, if I introduce a error here—

01:04 let’s say by calling the primt() function, which clearly doesn’t exist—as soon as I save the file, the linter will run and it’s going to call me out on that error and it’s going to tell me that I’m using an undefined name 'primt'.

01:16 The linter is also going to call me out on common formatting issues. For example, here, my code doesn’t follow the PEP 8 code style guide, and I can see that here in the linter error, where it says, “I expected another blank line between functions.” As soon as I insert that and save the file again, the error goes away.

01:33 And in here, I can see an error where the linter tells me that I shouldn’t compare to None using the == operator, but the recommendation is to use the is operator. And here I’m having some extra whitespace that I should clean up. All right, now the file is nice and clean.

01:50 Another cool feature that I’m going to show you how to add to your Sublime Text setup is Python code completion. What I can do here is just type the name of a module.

02:00 And already, as I’m typing this out, I will get the docstring for that module and the Python documentation displayed inline, so I can make sure that I’m actually using the right object here.

02:11 As I type out a dot (.) I get all the functions in the time module. And then I can find the right one, again by checking the docstring that gets displayed inline. As soon as I accept that autocompletion, the docstring still stays here and tells me what the arguments to this function are. Of course, the autocompletion also works with modules. Let’s say here, we want to import the namedtuple function from the collections module.

02:34 I can do that no problem and, again, get the docstring displayed inline. Yet another cool IDE-like feature is the ability to jump to the definition of a Python symbol. I can just click on Goto Definition and this will take me directly to the actual implementation in the Python standard library. Of course, the jump to definition also works for my own code.

02:52 I can just right-click on Cancel Job here and then click Goto Definition, and it would jump me directly to where that class is defined in my Python code.

03:02 This is a killer feature for working with any kind of larger codebase inside Sublime Text. I showed you some of the formatting errors that could be detected by the linter, and I want to introduce some more here. When I saved that file, the linter complains about the incorrect formatting of this file. Now, a quick way to fix that is by triggering the PEP 8 autoformat,

03:23 and that will take care of it and I don’t have to worry about it any more.

03:27 I’ll also show you how to integrate the Git source control system with Sublime Text. So, a couple of cool features to demo here. This file is actually part of a Git repository that I cloned earlier.

03:39 And now when I go in and delete a bunch of lines here or make modifications to this line, and as I edit the code, I get these symbols here next to the line numbers that are telling me exactly what was changed here. So for example, it tells me here that I modified a line, and here it looks like I deleted a bunch of lines. Now, when I place the mouse cursor over this symbol, I can see what was changed here and I can actually go and roll back the change directly from within Sublime Text. I don’t have to work with an external Git tool to get that done, and it’s really fluid and really flexible.

04:09 You might’ve also noticed that I’m running a custom editor font here. In the course, I’m going to show you how to set that up and basically how to install any font you find on the internet inside your Sublime Text editor, because there are so many awesome choices for programming fonts available.

04:23 There are also a couple of changes you can make to the font rendering settings to really tweak the look and feel of the editor area to make sure the code is perfectly legible and just a joy to look at.

04:33 I will also show you how to set up Sublime Text to make it easier for you to write beautiful, PEP 8 compliant code. So for example, we’re going to add a bunch of helper lines here that will make sure that you can adhere to the line length limits and we’re going to set up the editor to trim trailing whitespace so that you don’t have to worry about managing this really boring aspect yourself.

04:57 I will also teach you how to integrate Sublime Text with your command line setup with the subl command so that you can just go subl and then the name of a folder, for example, and it will open right up in your Sublime Text.

05:09 Or you can use the subl command to create a new file, and it will open up in your editor immediately. There are many more useful things you can do with Sublime Text from the command line—for example, use it as your Git commit editor.

05:21 You can write your commit messages inside Sublime Text with beautiful syntax highlighting and recommendations for line length again.

05:30 Now, this was just an overview and there are many more tips and tweaks in the full course, so I’m looking forward to working with you through the whole thing and I’m going to teach you how to set up Sublime Text, Git, and Python and really make them work together well so that you have a great setup that will work exactly the way you want it to.

You must own this product to join the conversation.