Python bin() Function

Python’s built-in bin(integer) function takes one integer argument and returns a binary string with prefix “0b”. If you call bin(x) on a non-integer x, it must define the __index__() method that returns an integer associated to x. Otherwise, it’ll throw a TypeError: object cannot be interpreted as an integer. Argument integer An integer value or … Read more

Premature Optimization is the Root of All Evil

This chapter draft is part of my upcoming book “The Art of Clean Code” (NoStarch 2022). You’ll learn about the concept of premature optimization and why it hurts your programming productivity. Premature optimization is one of the main problems of poorly written code. But what is it anyway? Definition Premature Optimization Definition: Premature optimization is … Read more

Python Regex Finditer()

You can create an iterable of all pattern matches in a text by using the re.finditer(pattern, text) method: Specification: re.finditer(pattern, text, flags=0) Definition: returns an iterator that goes over all non-overlapping matches of the pattern in the text. The flags argument allows you to customize some advanced properties of the regex engine such as whether … Read more

list.clear() vs New List — Why Clearing a List Rather Than Creating a New One?

Problem: You’ve just learned about the list.clear() method in Python. You wonder, what’s its purpose? Why not creating a new list and overwriting the variable instead of clearing an existing list? Example: Say, you have the following list. If you clear the list, it becomes empty: However, you could have accomplished the same thing by … Read more

Python Regex Multiple Repeat Error

Just like me an hour ago, you’re probably sitting in front of your regular expression code, puzzled by a strange error message: Why is it raised? Where does it come from? And, most importantly, how can you get rid of it? This article gives you answers to all of those questions. Alternatively, you can also … Read more

Exponential Fit with SciPy’s curve_fit()

In this article, you’ll explore how to generate exponential fits by exploiting the curve_fit() function from the Scipy library. SciPy’s curve_fit() allows building custom fit functions with which we can describe data points that follow an exponential trend. In the first part of the article, the curve_fit() function is used to fit the exponential trend … Read more

Law of Demeter

This tutorial gives you a short explanation of the Law of Demeter. It’s based on a rough chapter draft for my upcoming book “The Art of Clean Code” to appear with NoStarch in 2022. Overview You’ve already learned that one of the most important reasons for code complexity is interdependency. To write clean code, you … Read more

Show Don’t Tell: Commenting Python Best Practices

This tutorial taken from my upcoming programming book “From One to Zero” (NoStarch, 2021) will show you how to write great comments. While most online tutorials focus on a bullet list of commenting tips, we dive deeper into the meat exploring the underlying reasons for the commonly recommended commenting principles. So, let’s get started! Code … Read more

Freelance Developer – How to Code From Home and Earn Six Figures [Industry Report]

Six Figure Coder

What keeps you going day after day? Your motivation is the most important building block of your success. In the following, I’d like to give you some fact-based motivation why creating your coding business online can easily be the most rewarding decision in your life.Β  Yet, motivation is not everything. If you want to make … Read more

Matplotlib Scatter Plot – Simple Illustrated Guide

Scatter plots are a key tool in any Data Analyst’s arsenal. If you want to see the relationship between two variables, you are usually going to make a scatter plot.  In this article, you’ll learn the basic and intermediate concepts to create stunning matplotlib scatter plots. Minimal Scatter Plot Example The following code shows a … Read more