Photo by ThisIsEngineering from Pexels

Using @functools.singledispatch and type annotations.

Method and Function overriding is an extremely useful technique. It allows you to define the same method multiple times in your code — but with each method taking parameters of a different type.

Methods are defined on classes. Overloading is what happens when a child class redefines the method available in a parent class. Therefore we call this method overloading. I won’t be discussing method overloading in this article.

Functions are not defined on class objects (normally). When we define multiple versions of a function, it is called function overriding. This article is about function overriding in Python.

Let’s use…

Worms Eye View of Spiral Staircase

Let’s explore many different methods and techniques for calculating the Fibonacci Series using Python.

The Fibonacci Series is beautiful, fascinating, mysterious! The series is defined as follows: every number is the sum of the two preceding ones. Simple:

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...

The simplest way to calculate a Fibonacci number (n) is simply to start at the beginning and work forwards, iteratively. This solution calculates all previous values, giving it an exponential running time — larger numbers take increasingly longer to calculate.

The recursive approach to finding Fibonacci numbers… Thanks to

Beginner guide to understanding Python’s slice object.

If you’re unsure about how Python indexes and slices strings, this article is for you! First, let’s explore indexes. (Indices for the grammatically correct!).

This is a companion article to my beginner series:

The first element in a sequence has the index 0. Not 1. This is often a source of confusion!

Image credit:

Some reusable python recipes for manipulating bits to perform fast arithmetic.

Use the << operator to shift bits one place to the left, thereby doubling an integer.

Use the >> operator to shift bits one place to the right, thereby halving an integer.

This is more complicated. The pseudocode algorithm is:

while a ≠ 0
c ← b and a
b ← b xor a
left shift c by 1
a ← c
return b

Which, in principle, uses a loop which ends when the first integer reaches 0 — all of its bits have been added to…

The list is everywhere in Python. Up your game with these tips and tricks.

This article is for Python programmers who have gone beyond the basics of using lists, but would like to see some interesting concepts. It isn’t very advanced and should be easy for you to understand.

Sets contain unique elements but are unordered. On the other hand, lists can contain duplicate elements but retain their insertion order.

This example shows one way to get the benefits of both sets and lists — an ordered sequence of unique elements.

We are subclassing the Python built-in collections.UserList object. We could subclass list, or use to create a new abstract base class of…

Image Credit:

Dictionaries are the heart and soul of Python. Here are the most essential tips and tricks for you to use with dictionaries.

The following code snippets are available on Github as Gists, and were tested with Python 3.7. This is a companion article to:

This is a recursive solution to printing all k:v pairs in a dictionary.
It handles the presence of lists, sets and tuples in a value.

This is the output produced:

Image Credit:

String manipulation is something we Pythonistas do a lot. Here are 20 top tips & tricks you might find useful!

All these examples are using Python 3, at the time of writing the latest version is 3.8.2. If you’re new to programming, you’ll find my Introduction to Strings article useful.

Use the in-built comparator in which returns True or False

Use a slice with a decreasing step to return the reversed string.

Compare equality using == to see if two objects have an equal value. …

Pexels pexels-photo-207691 credit Pixabay

It was mostly painful. Herein follows a compression algorithm for experience.

1. The AWS training ecosystem is a hot mess of different websites and flaky SSO protocols. Be prepared to login several times. Your account is used, not your AWS account, for … reasons. Your entry point is ¯\_(ツ)_/¯

2. You can schedule “At Home Alone” AWS certifications via PearsonVue. (Entry point listed above). This requires waving away any privacy you had left and installing their super-pervasive “Online Proctoring” software. Nothing to see here.

3. If you take the $90 cloud practitioner exam, and then pass said exam…

Image credit to

I use these utilities every day to make my Python code presentable. They’re free and easy to use.

Writing beautiful Python is harder than it seems. As part of my release workflow, I use the following tools to make my code presentable and to remove avoidable mistakes.

1. Black

At #1 we have Black. Black is a no-compromises Python code reformatter. It will make sure that your code meets the PEP 8 recommendations.

You can get black from pypi using pip3:

pip3 install --upgrade --user black

Black has rich options, use black -h to print the help text.

black -t py38 --check…

Image credit:

Let’s explore the powerful object-oriented programming concepts available to us in Python!

This article is part of the course “Object-Oriented Python — for Beginners”. If you’re looking for a more beginner-oriented “Introduction to Python” course, I created one just for you! This course takes things a step further and delves deep into object-oriented Python. Earlier we saw how the tuple data type is used to create a record. The class can do the same, but it also allows us to bundle functions alongside the data.

Python is an object-based programming language. Every data type, and every variable, is an object…

Richard Quinn

I am a software engineering manager with over 25 years of experience. I am working to improve people’s health. Based in Basel, Switzerland.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store