Write More Pythonic Code

Learning PathSkills: Zen of Python, PEP 8 Standards, Application Layouts, Duck Typing, Type Checking, Type Hints, Code Documentation, MkDocs, Clean Code, Maintainable Code

A set of three light bulbs with Python symbols on them, followed by a rocket ascending into space

Write more Pythonic code with this path. Understand the Zen of Python, PEP 8 standards, application layouts, duck typing, type checking, and documentation using MkDocs. Enhance your coding style and project maintainability.

Write More Pythonic Code

Learning Path ⋅ 15 Resources

Title image for What's the Zen of Python? (What's the Zen of Python?)

Tutorial

What's the Zen of Python?

In this tutorial, you'll be exploring the Zen of Python, a collection of nineteen guiding principles for writing idiomatic Python. You'll find out how they originated and whether you should follow them. Along the way, you'll uncover several inside jokes associated with this humorous poem.

Title image for Writing Idiomatic Python (Python Best Practices Artwork)

Course

Writing Idiomatic Python

What are the programming idioms unique to Python? This course is a short overview for people coming from other languages and an introduction for beginners to the idiomatic practices within Python. You'll cover truth values, looping, DRY principles, and the Zen of Python.

Title image for Writing Beautiful Pythonic Code With PEP 8 (How to Write Beautiful Python Code With PEP 8)

Course

Writing Beautiful Pythonic Code With PEP 8

Learn how to write high-quality, readable code by using the Python style guidelines laid out in PEP 8. Following these guidelines helps you make a great impression when sharing your work with potential employers and collaborators. This course outlines the key guidelines laid out in PEP 8.

Title image for How to Write Pythonic Loops (Python Best Practices Artwork)

Course

How to Write Pythonic Loops

See how you can make your loops more Pythonic if you're coming to Python from a C-style language. You'll learn how you can get the most out of using range(), xrange(), and enumerate(). You'll also see how you can avoid having to keep track of loop indexes manually.

Title image for Using List Comprehensions Effectively (Intermediate Python)

Course

Using List Comprehensions Effectively

This short course breaks down Python list comprehensions for you step by step. See how Python's comprehensions can be transformed from and to equivalent "for"-loops so you'll know exactly what's going on behind the scenes.

Title image for Python Code Quality: Tools & Best Practices (Python Code Quality Illustration)

Tutorial

Python Code Quality: Tools & Best Practices

See how to improve the quality of your Python code. We'll analyze and compare tools you can use to take your code to the next level and make it more Pythonic. Whether you've been using Python for a while, or just beginning, you can benefit from the practices and tools talked about here.

Title image for Writing Cleaner Python Code With PyLint (Intermediate Python)

Course

Writing Cleaner Python Code With PyLint

See how to install and set up the PyLint code linter tool. You'll learn why you should use code linters like PyLint, Flake8, PyFlakes, or other static analysis tools—and how they can help you write cleaner and more Pythonic code.

Title image for Structuring a Python Application (Python Application Layouts and Project Structures)

Course

Structuring a Python Application

This course is a reference guide to common Python application layouts and project structures for command-line applications, web applications, and more.

Title image for Refactoring Python Applications for Simplicity (Refactoring Python Applications for Simplicity)

Tutorial

Refactoring Python Applications for Simplicity

Learn how to refactor your Python application to be simpler and more maintainable and have fewer bugs. You'll cover code metrics, refactoring tools, and common anti-patterns.

Title image for Duck Typing in Python: Writing Flexible and Decoupled Code (Duck Typing in Python: Writing Flexible and Decoupled Code)

Tutorial

Duck Typing in Python: Writing Flexible and Decoupled Code

Learn about duck typing in Python. It's a typing system based on objects' behaviors rather than on inheritance. By taking advantage of duck typing, you can create flexible and decoupled sets of Python classes that you can use together or individually.

Title image for Python Type Checking (The Ultimate Guide to Python Type Checking)

Course

Python Type Checking

In this course, you'll look at Python type checking. Traditionally, types have been handled by the Python interpreter in a flexible but implicit way. Recent versions of Python allow you to specify explicit type hints that can be used by different tools to help you develop your code more efficiently.

Title image for Python Type Checking (The Ultimate Guide to Python Type Checking)

Interactive Quiz

Python Type Checking

Title image for Using Type Hints for Multiple Return Types in Python (How to Use Type Hints for Multiple Return Types in Python)

Course

Using Type Hints for Multiple Return Types in Python

Learn how to define multiple return types using type hints in Python. This course covers working with single or multiple pieces of data, defining type aliases, and performing type checking using a third-party static type checker tool.

Title image for Documenting Code in Python (Documenting Python Code Guide)

Course

Documenting Code in Python

Whether you're documenting a small script or a large project, whether you're a beginner or seasoned Pythonista, this guide will cover everything you need to know.

Title image for Building Python Project Documentation With MkDocs (Build Your Python Project Documentation With MkDocs)

Course

Building Python Project Documentation With MkDocs

Learn how to build professional documentation for a Python package using MkDocs and mkdocstrings. These tools allow you to generate nice-looking and modern documentation from Markdown files and, more importantly, from your code's docstrings.

Continue Learning

Grab a copy of Python Tricks: The Book to continue your learning journey. Discover and train Python’s best practices with simple examples and start writing beautiful and pythonic code

Title image for Python Tricks: The Book (Python Tricks: The Book)

Book

Python Tricks: The Book

A Buffet of Awesome Python Features: Discover Python's best practices with simple examples and start writing beautiful and pythonic code

Got feedback on this learning path?

Looking for real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session. Happy Pythoning!

« Browse All Learning Paths