Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

What PEP 8 Is and Why You Need It

Give Feedback

This lesson introduces the course by giving you an overview of what to expect in the entire course and explains why you should care about PEP 8. You’ll see that PEP 8 exists to improve the readability of Python code, helps you collaborate well with others and makes it easier for them to understand the code you write.

00:00 Hey there! Welcome to the Real Python guide on how to write beautiful Python code with PEP 8. In this set of videos, you’ll learn how to write code that conforms to PEP 8, understand the reasoning of why PEP 8 was laid out, and how to set up your development environment to start writing PEP 8 compliant Python. So, why should you care about PEP 8?

00:23 PEP 8 refers to a document that contains guidelines and best practices on how to write Python code. If you’re not familiar with the Zen of Python, open a terminal and import this to see it.

00:38 Go to your terminal and start the Python interpreter. Then, just import this, just like that. You’ll see the Zen of Python print out to your console.

00:51 This is a pretty cool Easter egg of Python that gives you some tips on how to write good Python code. If you look down here, one of the lines is Readability counts. So, why is that?

01:06 Guido van Rossum said that “Code is read much more often than it is written.”

01:12 If you think about this, it makes sense. You may write a line of code once, but if you ever go back to refactor it or modify it, you have to read it again and know why you put it there.

01:21 This could be weeks or months after you wrote it. PEP 8 is designed to help you when you come back to a piece of code so you know why you did what you did by giving you a structure to your process.

01:34 It also helps if you want to work with others. If you and your team are all writing to the same standards of code, it becomes much easier to collaborate. This becomes especially important if you’re looking to get a development job, as you’ll be expected to work well with others.

01:49 Now that you know a little bit of the why behind PEP 8, let’s take a look at some examples so that you can start writing some beautiful Python.

Hi All, Please could you help me understand which one is better pylint or flake8? Also, is there any way to configure flake8 with pycharm? Thanks in advance! Regards, Anu

Become a Member to join the conversation.