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?

⚠️Why you should avoid import * in Python 🐍

Anyone who’s worked with Python knows that modules can be a Godsend, saving you time, effort, and many lines of code. They even have namespacing built-in 💪 😍 To expand on this a bit: However, not all ways of using modules are equally beneficial. In this article, we will discuss why using import * can… Continue reading ⚠️Why you should avoid import * in Python 🐍

The Arbitrary (Keyword) Arguments (args and kwargs) don’t come “for free” in Python

Python allows you to use *args and **kwargs in function definitions to accept an arbitrary number of positional and keyword arguments, respectively. Here is a simple example: Different types of function arguments In the above example, the arbitrary_args function is defined to accept any number of positional and keyword arguments using the *args and **kwargs… Continue reading The Arbitrary (Keyword) Arguments (args and kwargs) don’t come “for free” in Python