Modern Python Projects Transcripts
Chapter: Writing code
0:00 Another popular category of tools that can help you, while you write code is called linters
0:05 Unlike the black formatter that we saw in the previous lesson. Linters, don't modify your code,
0:12 but they will give you a real time feedback about your code. The two most popular Linters for Python are pylint and flake 8.
0:20 Let me show you how they work. For testing, I wrote another ugly piece of code. I swear this is not how I usually write code, as you can see. First,
0:29 I'm importing a non existing function that well, doesn't exist in this module. Then I import os module, but I actually don't even use it.
0:38 Then I create a class, that looks OK, but has some additional white spaces here and there, and it doesn't have empty lines between functions.
0:47 Then I have a function that it's supposed to create an instance of this class and print my name. But as you can see,
0:54 first, I use a variable that it's not even defined. And then I don't use this me variable.
0:59 But I use the Python class instead. So this code won't even work, by default with Only, The Python extension installed.
1:06 We already have some feedback saying that this variable is undefined. You can actually see the list of all problems.
1:14 Yeah, only one problem. And even if we change this unnamed variable to something
1:18 that actually exist, this code still won't work because this non existing function cant be imported. And even if we remove this import,
1:27 the code will work. But it won't work as expected, because I wanted to print my name.
1:32 But I made a mistake. And instead I will probably get none, let's actually run to see it. Yeah, As you can see,
1:38 nothing was printed because me is not passed my function. I could actually go here and replace person with me.
1:46 And it still doesn't work because it's not main. It's a double underscore main (__main__). And finally we get those results.
1:55 As you can see, one way to the debug this code is to rerun it, and each time try to fix whatever error we have
2:00 But a lot of those errors can actually be spotted when you install a linter So, let's install, pylint and flake 8 and see what they can tell us.