Blog Posts
-
What Is Monkey Patching?
dr. Dobreff Csaba 10th jan 2026Python is a remarkably flexible language when it comes to defining attributes.Because of this, Python users may encounter the term monkey patching, which refers to dynamically extending or modifying an...
-
When to use an operator vs a function?
dr. Dobreff Csaba 10th jan 2026In Python, most problems can be solved in several ways using different language constructs. For example, many operations have dedicated operators, but there are also functions or methods that achieve...
-
Using reduce() When You Need the Index
dr. Dobreff Csaba 10th jan 2026The reduce() function from the functools module in Python’s standard library is typically recommended for tasks that cannot be easily expressed using built-in language constructs such as comprehensions (list, set,...
-
Did You Know Context Managers Aren’t Just for File Operations?
dr. Dobreff Csaba 10th jan 2026When you first learn about context managers in Python — specifically the with…as… syntax — they’re usually introduced through file handling examples. That’s no surprise, since managing files safely is...
-
Be Careful: None Is Falsy, But Not Everything Falsy Is None
dr. Dobreff Csaba 10th jan 2026Let’s say we want to write a function that takes two arguments and runs a specific code block inside its body only if neither of the arguments is None. We...
-
OrderedDict Isn’t Dead Yet — Here’s Why
dr. Dobreff Csaba 10th jan 2026Do you still need [crayon-6adfed117b637054556742-i/] in your code now that dict preserves insertion order? Sometimes, we need dictionary items (key-value pairs) to retain the order in which they were added....
-
How to Define Truly Immutable Constants in Python
dr. Dobreff Csaba 10th jan 2026At first, this question might sound contradictory—after all, isn’t the whole point of a constant that its value doesn’t change? In theory, yes. But in practice, things are a bit...
-
How to Extract Elements from Deeply Nested Iterable Objects into a Single Container?
dr. Dobreff Csaba 10th jan 2026Let’s suppose we have a container object (such as a tuple) whose elements may include other containers, and those containers may themselves contain further containers. The goal is to create...
-
How to simplify the code and improve its readability with the partial() function?
dr. Dobreff Csaba 10th jan 2026The [crayon-6adfed117b91c382065186-i/] function in the [crayon-6adfed117b91f925380187-i/] module is used to create a new callable object from a callable object having multiple parameters by fixing the values of certain parameters, thus...
-
Why Are Annotations Useful?
dr. Dobreff Csaba 10th jan 2026In addition to comments written above or beside lines of code, as well as documentation strings (docstrings), Python also allows us to use annotations to help improve the understanding of...