Real Python Podcast E273 Title Image

Episode 273: Advice for Writing Maintainable Python Code

The Real Python Podcast

What are techniques for writing maintainable Python code? How do you make your Python more readable and easier to refactor? Christopher Trudeau is back on the show this week, bringing another batch of PyCoder’s Weekly articles and projects.

We discuss a recent article about writing code that is easy to maintain. We cover writing comments, creating meaningful names, avoiding magic numbers, and preparing code for your future self.

We also share several other articles and projects from the Python community, including release news, modifying the REPL, differences between Polars and pandas, generating realistic test data in Python, investigating quasars with Polars and marimo, creating simple meta tags for Django objects, and a GUI toolkit for grids of buttons.

Topics:

  • 00:00:00 – Introduction
  • 00:01:53 – PyTorch 2.9 Release
  • 00:02:38 – Django 6.0 Beta 1
  • 00:03:05 – Handy Python REPL Modifications
  • 00:11:06 – Polars vs pandas: What’s the Difference?
  • 00:17:55 – Faker: Generate Realistic Test Data in Python
  • 00:22:06 – Video Course Spotlight
  • 00:23:35 – Investigating Quasars With Polars and marimo
  • 00:27:37 – Writing Maintainable Code
  • 00:49:48 – buttonpad: GUI Toolkit for Grids of Buttons
  • 00:52:10 – django-snakeoil: Simple Meta Tags for Django Objects
  • 00:54:07 – Thanks and goodbye

News:

Show Links:

  • Handy Python REPL Modifications – Trey uses the the Python REPL a lot. In this post he shows you his favorite customizations to make the REPL even better.
  • Polars vs pandas: What’s the Difference? – Discover the key differences in Polars vs pandas to help you choose the right Python library for faster, more efficient data analysis.
  • Faker: Generate Realistic Test Data in Python – If you want to generate test data with specific types (bool, float, text, integers) and realistic characteristics (names, addresses, colors, emails, phone numbers, locations), Faker can help you do that.
  • Investigating Quasars With Polars and marimo – Learn to visualize quasar redshift data by building an interactive marimo dashboard using Polars, pandas, and Matplotlib. You’ll practice retrieving, cleaning, and displaying data in your notebook. You’ll also build interactive UI components that live-update visualizations in the notebook.

Discussion:

  • Writing Maintainable Code – “Maintainable code can easily be the difference between long-lived, profitable software, and short-lived money pits.” Read on to see just what maintainable code is and how to achieve it.

Projects:

Additional Links: