You will encounter the term PEP within your first week of learning Python. Most tutorials tell you it stands for Python Enhancement Proposal and then move on. This tutorial does not do that. Here you will learn exactly what PEPs are, why they were created, and — more importantly — why two specific PEPs will change how you write Python code starting today.
Python is a language used by millions of developers worldwide. For that ecosystem to function, everyone writing Python needs to work from a shared understanding of what good Python looks like. That shared understanding comes from PEPs — numbered design documents that govern how the language evolves and how code in it should be written. Some PEPs add features to the language. Others define how you format a variable name. Once you understand the system, a lot of Python behavior that previously seemed arbitrary will start to make sense.
What Is a PEP and Why Does It Exist?
A Python Enhancement Proposal is a formal design document used to communicate ideas to the Python community. PEP 1, which describes the purpose and guidelines for writing PEPs, defines them as the primary mechanism for proposing major new features, collecting community input on issues, and documenting design decisions. That is a lot to take in, so here is a more grounded way to think about it.
Imagine you are working on a large open-source project with thousands of contributors. Someone wants to add a new feature. How does that idea get submitted, debated, and approved without chaos? PEPs are that process. They give every proposal a number, a structure, a status, and a paper trail. Because PEPs are stored as text files in a public version control repository, the full history of every proposal — including rejected ones — is permanently available at peps.python.org.
The Python Steering Council serves as the final decision-making body for PEPs. It is an elected group drawn from Python's active core developers, established by PEP 13. Before a proposal ever reaches the council, it goes through community discussion and review by core contributors.
PEPs are not just for core developers. Informational PEPs — including the ones you will use the most as a beginner — are written for the entire Python community. They define how Python developers are expected to think, write, and structure code. Learning to recognize PEP references in documentation, linter output, and code reviews is a practical skill that pays off immediately.
Build the correct Python function signature for a PEP-8 compliant function named get_pep_status that takes one parameter called pep_number:
snake_case — lowercase words separated by underscores. getPepStatus is camelCase, which is the convention used in languages like JavaScript and Java, not Python. The keyword is def, not function. The correct order is: def, then the function name, then (, then the parameter, then ), then :.
The Three Types of PEPs
Not all PEPs propose new language features. There are three distinct categories, and understanding the difference tells you exactly what kind of information you are reading when you open one.
- Purpose
- Proposes a new feature or implementation for Python itself. This includes changes to the language syntax, the standard library, or interoperability standards.
- Example
- PEP 484 introduced type hints. PEP 572 added the walrus operator (
:=). Both changed what Python code can express.
- Purpose
- Provides general guidelines, design philosophy, or background information to the Python community without proposing a mandatory change.
- Example
- PEP 20 (the Zen of Python) is informational. It describes how Python developers should think about code. Developers are free to follow or ignore it, though the community strongly favors it.
- Purpose
- Describes or proposes a change to the Python community's workflows, governance, or decision-making process. These require community consensus and are generally binding.
- Example
- PEP 13 defines the structure and authority of the Python Steering Council. PEP 1 itself — the document that defines how PEPs work — is a Process PEP.
Rejected PEPs are still published and remain permanently visible. They contain valuable discussion about Python's design philosophy and often explain why a particular approach was deliberately left out of the language. Browsing a rejected PEP can teach you as much as an accepted one.
PEP 8: The Style Guide That Shapes Your Code
PEP 8 is the document that will affect your daily work the most. It defines the official coding style for Python — covering indentation, spacing, naming, line length, comments, and more. It was adapted from Guido van Rossum's original Python Style Guide essay and has been updated over time as the language evolved.
When you read Python documentation, open-source code, or Stack Overflow answers from experienced developers, you are looking at code shaped by PEP 8. When a linter like flake8 or an IDE like VS Code underlines part of your code, it is often enforcing a PEP 8 rule. Understanding the rules directly — rather than just relying on automated tools — makes you a more intentional programmer.
"Code is read much more often than it is written." — PEP 8 (Guido van Rossum)
Naming Conventions
PEP 8 is specific about how things should be named. Variables and functions use snake_case. Class names use PascalCase. Constants use ALL_CAPS. These are not personal preferences — they are the agreed standard that makes it possible for any Python developer to read your code and immediately understand what each identifier represents.
# PEP 8 naming conventions
# Variables and functions — snake_case
user_name = "ada"
page_count = 42
def calculate_total(price, quantity):
return price * quantity
# Classes — PascalCase
class ShoppingCart:
pass
# Constants — ALL_CAPS
MAX_RETRY_LIMIT = 3
DEFAULT_TIMEOUT = 30
Indentation and Line Length
Python requires indentation to define code blocks, but PEP 8 specifies exactly how to do it: 4 spaces per level, never tabs. The maximum recommended line length for code is 79 characters. If a line of code is longer, you break it with parentheses or a backslash. These rules exist because different editors, terminals, and code review tools handle whitespace differently — a consistent approach avoids subtle bugs and visual inconsistencies.
# Good: 4-space indentation, line break with parentheses
def send_notification(user_id, message, priority,
retry_on_failure=True):
if priority == "high":
dispatch_immediately(user_id, message)
else:
queue_message(user_id, message)
# Bad: tabs mixed with spaces — causes IndentationError in Python 3
def bad_example():
x = 1 # tab used here — do not do this
PEP 20: The Zen of Python
PEP 20 is an informational PEP that contains 19 aphorisms describing the guiding philosophy behind Python. You can read it any time by running import this in a Python interpreter. The principles are short — each is a single sentence — but they encode a philosophy that distinguishes Python from other languages. Ideas like "Readability counts," "Explicit is better than implicit," and "Simple is better than complex" are not decorative sayings. They explain why Python looks the way it does and why the community rejects code that is clever at the expense of clarity.
# Run this in any Python interpreter to see PEP 20
import this
The function below violates a PEP 8 rule. One line breaks the naming convention. Click the line you think is wrong, then hit check.
discountedPrice to discounted_price. PEP 8 requires local variable names to use snake_case. discountedPrice is camelCase, which Python code should not use for variables or functions. The function name and parameter discount_rate are already correct. Consistent naming makes code easier to scan — a reader should not have to wonder why some names use underscores and others do not.
How to Apply PEP 8 Style Rules in Python
Reading PEP 8 is one thing. Applying it consistently is another. These four steps cover the rules you will use in almost every function you write as a beginner. Getting these right from the start means you will not need to unlearn bad habits later.
-
Use 4 spaces for indentation
Replace any tabs in your code with 4 spaces. Python allows both but PEP 8 requires spaces, and mixing the two causes an
IndentationErrorin Python 3. Configure your editor to insert 4 spaces when you press the Tab key — virtually every modern code editor has this setting. -
Follow naming conventions
Name variables and functions with
snake_case— words joined by underscores. Name classes withPascalCase— each word capitalized, no separators. Name constants withALL_CAPS. Consistent naming lets another developer read your intent at a glance without needing comments to explain the purpose of an identifier. -
Keep lines under 79 characters
PEP 8 recommends a maximum line length of 79 characters for code and 72 characters for docstrings and comments. If a statement runs long, break it inside parentheses across multiple lines. This keeps code legible in side-by-side diffs, terminals, and code review tools without horizontal scrolling.
-
Write docstrings for every function
Add a triple-quoted string immediately after the
defline of every function, class, or module. The docstring should describe what the object does, not the internal mechanics of how it does it. PEP 257 extends this convention with detailed docstring formatting rules that complement PEP 8.
"Readability counts." — PEP 20, The Zen of Python
Python Learning Summary Points
- A PEP is a numbered design document that serves as the formal mechanism for proposing features, collecting community input, and documenting Python design decisions. All PEPs — accepted, rejected, and superseded — are permanently available at peps.python.org.
- There are three categories of PEPs: Standards Track (propose language or library changes), Informational (document guidelines and philosophy without mandating change), and Process (govern workflows and community decision-making). As a beginner, the Informational PEPs — especially PEP 8 and PEP 20 — will shape your code the most immediately.
- PEP 8 defines the official Python style guide: 4-space indentation, snake_case for variables and functions, PascalCase for classes, ALL_CAPS for constants, and a maximum line length of 79 characters. These rules exist to make code consistent and readable across the entire ecosystem, not just within a single project.
- PEP 20, the Zen of Python, encodes the philosophy behind Python's design in 19 aphorisms. Running
import thisin any Python interpreter displays them. The principles explain why Python looks and behaves the way it does — and why the community values clarity over cleverness.
PEPs are the governance layer beneath everything Python. You do not need to read every PEP to write good Python code. You do need to understand that the conventions you will encounter — in linters, in open-source projects, in code reviews — trace back to decisions documented in these proposals. The two PEPs covered here, PEP 8 and PEP 20, are a practical starting point. Once they become second nature, the rest of the system will make more sense.
Frequently Asked Questions
PEP stands for Python Enhancement Proposal. A PEP is a formal design document that provides information to the Python community, proposes new language features, or describes changes to Python's processes and environment.
Beginners do not need to read every PEP, but knowing that PEPs exist and understanding PEP 8 (the style guide) and PEP 20 (the Zen of Python) will immediately improve how you write and read Python code.
PEP 8 is the official style guide for Python code. It defines conventions for indentation (4 spaces), naming, line length, spacing, and other formatting rules that make Python code consistent and readable across the ecosystem.
PEP 20 is an informational PEP containing 19 aphorisms that describe the philosophy behind Python's design. You can see them by running import this in a Python interpreter. It guides how Python developers think about writing code.
There are three types: Standards Track PEPs (propose new language features or implementations), Informational PEPs (document guidelines or design issues without requiring change), and Process PEPs (describe changes to workflows or governance around Python).
The Python Steering Council serves as the final decision-making body for PEPs. It is an elected group drawn from Python's active core developers. Before reaching the council, a PEP goes through community discussion and review by core contributors.
All live and draft PEPs are published at peps.python.org. Each PEP has its own numbered page. PEP 0 contains a full index of all proposals organized by status and category.
An Accepted PEP has been approved by the Steering Council but may not yet be implemented. A Final PEP has been accepted and fully implemented in Python. The status reflects where the proposal sits in the lifecycle from draft to completed feature.