Home
k0nze
Cancel

Python’s Abstract Base Classes (ABC) and Interfaces Explained (With Code Snippets)

thumbnail
When you get started with object-oriented programming, you will come across interfaces and abstract classes. Especially languages like Java or C# make use of those two concepts a lot to structure complex programming projects and to leverage abstraction. However, in Python, interfaces and abstract classes aren’t part of the standard languages’ definition. In this article,...

Python Decorators, A Beginners Guide (With Code Examples)

thumbnail
When looking through Python code of other programmers or though the code of Python modules, you might have come across functions or methods which have a string on top of their signature starting with a @. Those markers on top of functions and methods are called decorators and in this article you are going to...

Python := / Walrus Operator Explained in Simple Terms (With Code Snippets)

thumbnail
Since the version 3.8 Python has a new operator, officially called the assignment expression operator :=, because of its looks the Python community gave it the name walrus operator. In this article, you will learn what the walrus operator does, how to use it, and how to improve the quality of your code with the...

Python *args, **kwargs, and Star/Asterisk-Operator Explained in Simple Terms (With Code Snippets)

thumbnail
You just discovered a cool Python module that helps you to implement your program much more elegantly or even faster and while you are digging through the code and documentation you come across *args and **kwargs in functions and classes of the module and ask yourself what do those two cryptic things do? In this...

A Python Program that Self-destructs but Makes a Clone of Itself Just in Time to Stay Alive

thumbnail
This article shows how to write a Python program which destructs itself when it is called, by deleting its own source code, and then creates a copy of itself just to call this copy to “live” on forever while reproducing itself. You might ask, why would anyone ever need such a program? I must admit...

Verilog Development on Apple Silicon Macs (M1/M2/M3) - A Step-by-Step Guide to Setting up Verilator, SystemC and GTKWave on macOS

thumbnail
Hardware development often depends on proprietary EDA software coming from Synopsys or Cadence, however, this software is only available on Linux and Windows with license fees unattainable for a student or hobbyist. The open-source tool Verilator allows everyone to simulate Verilog code and interface it with C++. Setting up Verilator on an Intel Mac was...

How to install an Alternative C/C++ Compiler (GCC/Clang) on macOS (Apple Silicon Mac M1/M2/M3)

thumbnail
When installing the XCode command line tools, they also install the Apple Clang compiler for C/C++ and set several symbolic links which shadow the gcc and clang commands and thereby redirecting every call of those commands to the Apple Clang compiler. If you only work with XCode to build Swift or Objective-C applications, the Apple...

Two Sum Problem Solution in C++ in O(n)

The “Two Sum Problem” is described as follows: Given an array of integers nums and an integer target, return the indices of the two integers in nums such that they add up to target. See Leetcode “Two Sum Problem” A solution with a time complexity of \(O(n)\) in pseudocode solution looks like this: array nums...

Big O Notation Explained

Why is Big O Notation Used? When you got different algorithms to solve the same problem, you need to compare those to each other to pick the best (meaning fastest) for your program. Looking at each algorithm’s (pseudo-) code will give you an insight into how they work and what data structures they rely on....

Python @staticmethod vs @classmethod

thumbnail
Python Functions are First-class Objects In Python functions are first-class objects which means that functions can be assigned to variables or passed as an argument for another function in the same manner as primitive data types and objects. For example, in the following code, the function operator has three parameters operation, x, and y. While...