User Session Management Primer

Most web applications need to handle user sessions at some point. The most common case is to remember an authenticated user across requests. Since HTTP is a stateless protocol, the only way for servers to know that one request is related to another (same user) is to associate them with some identifier provided by the […]

Learn Huffman Encoding With Python

In this post I’m going to walk through an implementation of huffman encoding and decoding in Python. For purposes of demonstrating key ideas, I’m going to just treat bits as plaintext strings just to keep things simple. While this means that the output isn’t truly compressed, you will hopefully take away a deeper understanding of […]

Python Dependency Inversion Principle

In this post I’ll show what dependency inversion looks like in the context of a dynamically typed language like Python. First, I’m going to introduce the concept of dependency inversion and what it means in a statically typed language like Java so that we can see differences between the two types of languages. Note: Robert […]

Nand2tetris Python Assembler

In this post I’m sharing my source code for the assembler for the nand2tetris HACK assembly language written in python 3. This implementation emphasizes readability above all else. Therefore, there are more function calls than necessary and many parts of the implementation assume best case inputs and do not cover corner cases. That said, it […]

Practical Guide to Python String Format Specifiers

Python 3.x introduced two key enhancements to string formatting: In this article I’m going to give specific examples on how format specifiers work using both .format and f-strings. Format specifiers give you much greater control over how you want your output to look, but the grammar can feel foreign and confusing if you’re coming from python 2 […]