What Is Pep8 (Python Enhancement Proposals) In Python?

What Is Pep8 (Python Enhancement Proposals) In Python?

Published on October 09 2023

In this tutorial, we will learn about PEP8 (Python Enhancement Proposals) in Python, its guidelines and best practices, and its importance. This tutorial is part of Python's top 25 most commonly asked interview questions.

Definition

  • PEP stands for Python Enhancement Proposal.
  • It is an official design document providing guidelines on how to write Python code.
  • It has a set of rules that specify how to format Python code for maximum readability.

Few Guidelines

  • Indentation
    • Use 4 spaces per indentation level.
  • Imports
    • Imports should usually be on separate lines
    • Example
import os
import sys
  • Function and Variable Names
    • Function names should be lowercase, with words separated by underscores as necessary to improve readability.
    • Variable names follow the same convention as function names.

To know about it, please refer to the official documentation website - official website.