Recently I came across a Reddit thread where someone asked: “I was thinking about using an Arduino, but I have been learning Python and do not want to learn a whole other programming language to do basic things that an Arduino can. (Planning on making a robot, will be using…
python
Combining Bazel with Docker
Welcome to the next pikoTutorial! In one of the recent articles, I showed how to build and run Docker containers using CMake. Today, we will see how to do a similar thing, but using Bazel. Today’s project structure: Note: on the contrary to the project structure used in the article…
Running commands with timeout on Linux
Welcome to the next pikoTutorial! Bash comes with a bunch of useful, built-in commands. One of them is timeout which allows you to run another command with a time limit. The syntax is simple: To avoid providing large numbers for long timeouts, duration parameter accepts suffixes which mark the exact…
Running Python unit tests with CMake
Welcome to the next pikoTutorial ! If you haven’t read the previous pikoTutorial on setting up a Python project with CMake, you may want to check it out first because in today’s article I’ll be using the setup we’ve done there: However, I will extend it with the test directories…
How to derive from an enum in Python?
Welcome to the next pikoTutorial ! Recently I’m experimenting with different ways of error handling in Python and I stumbled upon a use case in which it would be very helpful to create an enum by deriving from a different enum. Use case Let’s say we design an interface for…
Setting up a Python project with CMake
Welcome to the next pikoTutorial ! CMake is often associated only with C/C++ and occupies a high place in the ranking of the most hated tools. Today, I want to show an unusual, but interesting use case – setting up and running Python applications with CMake and its underlying generators.…
UDP multicasting with Python
Welcome to the next pikoTutorial! The minimal receiver Note for beginners: do not remove line 14 from the receiver implementation! Without the ability to re-use the same address, you will not be able to run more than 1 multicast receiver and you’ll end up with a simple UDP client/server setup.…
TCP client/server with Python
Welcome to the next pikoTutorial ! The minimal TCP server A TCP server listens for incoming connections on a specified port and communicates with clients over that connection. The minimal TCP client A TCP client establishes a connection with a server, sends data, and receives responses. Bidirectional communication You can…
Python lru_cache explained
Welcome to the next pikoTutorial! Imagine you’re developing an application that fetches data from external API. For example, a weather app might request current weather conditions for a list of cities and then display them. While the data is updated periodically, repeatedly querying the API with the same city is…
How to dockerize a Python application?
Welcome to the next pikoTutorial! If you ever wanted to ensure a consistent environment for your application, you most probably know that containerization is the way to go. To containerize a Python application, let’s first set up a simple file structure: Now add a simple Python application: Note for beginners:…
Python reduce explained
Welcome to the next pikoTutorial! The reduce function is a powerful tool placed in the functools module that facilitates the cumulative application of a function to the items of an iterable (from left to right), to reduce them to a single value. Initially introduced in Python 2, later moved to…
Bug of the week #6
Welcome to the next pikoTutorial! The error we’re handling today is a Python runtime error: What does it mean? The “too many values to unpack” error typically occurs when there is a mismatch between the number of variables or elements being unpacked and the number of values being assigned. This…
5 Python good practices which make life easier
Welcome to the next pikoTutorial! Print exceptions traceback after catching them Consider the following example code that raises an exception: When we run it, we see the following output: The traceback provides detailed information, including where the error occurred, the exception type, and the error message. However, the downside is…
Let’s review some code: Python #1
Below you can find the code that we will be reviewing today. Before you scroll down to section where I fix it, feel free to check how many mistakes you can find. This function is meant to take a list of strings, count the occurrences of each individual string and…
Make C++ a better place #1: What does better mean
Let’s define word “better” In the title of this series, I used the term “better”, but as an engineer, I can’t begin my research with such a vague objective. The world of software engineering is so complex and varied that word “better” can have very different meanings depending on the…
UDP client/server with Python
Unlike TCP (Transmission Control Protocol), UDP is connectionless, meaning it does not require a handshake process to establish a connection before data transmission.
Yield in Python – state machines, coroutines and more
yield is a well known keyword in Python which allows to optimize the code by generating data streams on the fly instead of generating the same data all at once.
Make C++ a better place #0: Introduction
The world of software development is built on dreams of engineers who aspired to create their own programming languages.
Key derivation function with Python
Below you can find the extended example of how to use PBKDF2HMAC key derivation function in Python.
Symmetric data encryption with Python
One of the simplest ways to perform symmetric encryption in Python is to use Fernet algorithm from cryptography module. Let’s see how to use it.
Hacking Python functions by changing their source code
Changing function by modifying its implementation manually is obvious, but can we change the implementation of the function at runtime of the application?
Welcome to pikoTutorial!
Your best source of byte-sized programming knowledge! Inspired by the SI unit prefix “piko” (10^-12), our portal aims to deliver short software tutorials.