What is the Repository Pattern and How to Use it in Python?

The repository pattern is a design pattern that helps you separate business logic from data access code. It does so by providing a unified interface for interacting with different data sources, bringing the following advantages to your system: A practical example Let’s use Python and sqlmodel (PyPI) to demonstrate this pattern (code here): Note: In this implementation,… Continue reading What is the Repository Pattern and How to Use it in Python?

Elevate Your Python: Harnessing the Power of Abstract Base Classes (ABCs)

Introduction One cool object-oriented programming (OOP) technique / pattern is enforcing consistent interfaces. In Python you can use Abstract Base Classes (ABCs) for that. 🐍 Using ABCs ensures that all subclasses implement the required methods. This can make it easier to maintain and extend the existing code base. Update Feb 2024: you can also leverage… Continue reading Elevate Your Python: Harnessing the Power of Abstract Base Classes (ABCs)

Exploring the Role of Static Methods in Python: A Functional Perspective

Introduction Python’s versatility in supporting different programming paradigms, including procedural, object-oriented, and functional programming, opens up a rich landscape for software design and development. Among these paradigms, the use of static methods in Python, particularly in an object-oriented context, has been a topic of debate. This article delves into the role and implications of static… Continue reading Exploring the Role of Static Methods in Python: A Functional Perspective

How the Flocking Rules Can Help You Refactor Your Code

In this new podcast episode we are excited to have Chris May back to delve deeper into the intricacies of refactoring. Watch here: Listen here: We talk about the significance of the Flocking Rules, a set of guidelines derived from “99 Bottles of OOP” by Sandi Metz and Katrina Owen.  These rules provide developers with… Continue reading How the Flocking Rules Can Help You Refactor Your Code

Django class based vs function based views

This post first appeared as an email on our friends list. We decided to publish it here because the question is still commonly asked 🤔 The other day I did a presentation on Django class based vs function based views. (Warning: this post is opinionated 😃) Also if you’re not into Django don’t stop reading just yet, because there are… Continue reading Django class based vs function based views

Documentation-driven development with Sebastián Ramirez

Listen here: This week Bob and Pybites Coach, Robin Beer, interview Sebastián Ramirez, the creator of FastAPI, Typer and SQLModel. We talk about:– What he is currently working on.– How to balance the large amount of opportunities in his space (open source developer productivity tips).– The process of designing new libraries that are the glue between other ones.– The feeling of… Continue reading Documentation-driven development with Sebastián Ramirez

Learning Python Decorators by Example

Decorators are a sometimes overlooked feature and they might be hard to grasp for beginning Pythonistas. I agree with Aaron Maxwell that mastering them “can massively magnify the positive impact of the code you write”, so make sure you add them to your toolkit if not done so already. In this article I explain what they do, why you want to use them and give some practical examples.