Coding Notes

First look at WSGI and PEP 3333

WSGI - Web Server Gateway Interface. This is Python standard interface between web server software and web applications. The specification was created in 2003 and described in PEP 333, further updated in 2010 in PEP 3333, with backward compatibility to prepare for Python 3 changes.

Playing with Python: Boolean of empty containers

It is funny that when one decides to refresh the basics of Python, watches the first video about types and is already stuck for an hour testing edge cases and wondering why? Let’s explore the bool function with empty containers.

Simple game menu in Python and Godot

Recently I have started to dive into game programming a bit more. Coming from Python with Pyglet, my current choice is Godot game engine. I created a simple text-based game menu in both to see what is easier for someone without any prior experience.

Entity-Attribute-Value (EAV) database model

Premature optimization - the root of all evil. Or something like: we think that in the future we will need this and that feature, though in reality, in most cases, we do not.

Sometimes when you come to the project, you see EAV database design, and some developers hate it, some do not have an opinion, and the rest do not care. Majority of database designers and developers would tell you that you should use a typical relational model, with all its tooling available out of the box, instead of handcrafting everything on your own. I agree on that, but is there a case when EAV is good?

Singleton Design Pattern in Python

Recently I dived into design patterns a little bit, to refresh a rusty knowledge. It is something we are using in Python daily, however not often realizing that. And I like reading those religious debates between programmers. One of them is the usage of Singleton in Python. Let’s see what is Pythonistas take on this beloved pattern.

Concurrency in Python - intro

The first paragraph from Python documentation about concurrency titled “Concurrent Execution” mentions a few phrases like, CPU bound, IO bound, event-driven cooperative multitasking or preemptive multitasking. In this intro post to concurrency, let’s clarify these definitions.

Parametrizing tests with pytest

In pytest we can parametrize in three different ways:

  • pytest.fixture() - allows to parametrize fixture functions
  • @pytest.mark.parametrize - allows to define arguments for a test function or class
  • pytest_generate_tests - allows to define custom parametrization schemes

This article presents a few examples of how to use parametrization in pytest using @pytest.mark.parametrize. The article starts from the basic tests, and end with the usage of ids and indirect.

Summary: Assignment Expressions - PEP 572

The famous PEP 572, and one of the reasons Guido Van Rossum - Python BDFL - retired from decision process (stepped down as BDFL). It is called “Assignment Expressions”, and is about adding new syntax := that will allow assign to variables within an expression.