About Me - The Short Story

I am a lonely Python/C++ coder with a background in financial markets and an interest in modern art. I am an application-driven guy, not a computer scientist. Sure I have many gaps in my knowledge, but I strive to do my best to fill them. I keep learning new things, listening to smart guys, correcting my mistakes, and pushing myself to the limits. I enjoy it.

I will use this website both as a blog and as a hub to some of my projects. It is written from scratch in Python's Flask, my favourite web-framework.


Find N largest or lowest values with heapq

You have a collection of items and you need to keep the N highest or lowest of them. Instead of writing your own algorithm, use build-in heapq module.

This module has two handy functions, nlargest(), and nsmallest().

This is...

python 
data-structures 
algorithms 


Into to Python Unicode

ASCII table has 128 code points, which is not sufficient for all the languages and accents, that is why Unicode was invented. It can have up to 1.114.112 code points. The first 128 code points are ASCII making in backward...

python 
unicode 
strings 


How to implement a tagging system in Flask

You have probably noticed that each article on this blog contains several tags, and these tags are hyperlinks so that when you click them, only articles containing the particular tag appears. Although it is very straightforward, at first I...

python 
flask 
jinja 


Filter a list based on a Boolean selector

I believe in code expressivity and this tip is exactly about that. Lately, I got into a situation where I had two lists and I needed to filter one based on the values of the other.

For that case, it is probably best to use compress...

python 
itertools 
compress 


Multithreading vs Multiprocessing. When to use what?

Multithreading and multiprocessing can be confusing because they aim to achieve the same - run your code faster. There is actually a huge difference between these two and in a way their use is quite opposite so if you mess up one with the...

python 
multithreading 
multiprocessing 


Observer design pattern in Python

The observer pattern is a useful design principle allowing some objects to be notified about a change that happens in another object. It provides a way to implement a "subscription mechanism", widely used in web, GUI, or...

python 
design patterns 
object-orientation 


Tuple is not just an immutable list

All too often I see people referring to tuple as an immutable list. Also many tutorials on Python present tuples just as a list that cannot be changed. Although it is true that tuple is immutable, there is actually much more to...

python 
data-structures 
tuple 
list 


Caveat when removing elements from Python list or dict

There is a caveat when removing duplications from a list in Python using for loop. One thing you have to keep in mind to make it correct is, that you need to iterate over a copy of the list, not the list itself.

Suppose you have this...

python 
data-structures 
list 
dict