Blog Posts
-
What is the Role of __main__, and When to Use It?
dr. Dobreff Csaba 10th jan 2026In Python scripts, you may sometimes see a code block starting with if __name__ == ‘__main__‘:, but it’s not always there. Why is that? The answer lies in the fact...
-
When and Why Should You Use Fractions in Calculations?
dr. Dobreff Csaba 10th jan 2026In earlier posts, we discussed how the [crayon-6a68c364dbd7c971667597-i/] module can help mitigate the precision limitations inherent in Python’s float type. However, even the [crayon-6a68c364dbd80443632777-i/] type cannot provide infinite precision. This...
-
How to Round Numbers in Python
dr. Dobreff Csaba 10th jan 2026In the previous post, we used Python’s standard library [crayon-6a68c364dc190943078666-i/] module for applications that require high precision. We also saw examples showing how changing the desired precision through the context...
-
How to Perform Calculations Requiring High Numerical Precision
dr. Dobreff Csaba 10th jan 2026When you perform arithmetic operations in Python using float operands, you may notice that the results aren’t always exact—even when the expected outcome is a finite decimal or an integer...
-
Coroutines and Their Applications
dr. Dobreff Csaba 10th jan 2026In the previous post, we talked about generators. We described them as special kinds of iterators that allow two-way data transfer between the calling program and the generator itself. This...
-
Do You Know the Difference Between an Iterator, a Generator, a Generator-Iterator, an Iterator Generator, a Generator Function, and a Generator Expression?
dr. Dobreff Csaba 10th jan 2026This is not a play on words — these are fundamental Python concepts that may not be entirely clear to everyone learning the language. Let’s briefly summarize their essence below....
-
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...