The Good, the Bad, and the Ugly of Tuple Unpacking

Python has this neat feature of unpacking tuples during item assignment. Here’s a general example:

or if you have a function that returns multiple items:

But what if (for some reason) you have a function that returns some large number of variables (or a smaller number of long-named …

An Introduction to Python’s Types

In this post we’ll talk about python’s types, how to use them, how they’re treated, and what we can do with typing. This is aimed at beginners who have heard the words “Python” and “Types” but haven’t quite nailed down what they have to do with each other. This is …

A quick guide to os.fork in Python

Paralellization usually is pretty tricky in python, however there’s a super easy way to implement pretty straightforward parallelization using the built-in os.fork() functionality. Let’s talk about what os.fork() actually does. In short, it simply creates an additional copy (referred to as the “child process”) of the running program at the …

Solving Political Boundaries Through Simulation

In this writeup we’ll discuss two algorithms, simulated annealing and genetic algorithms, and show how they can be applied to the problem of drawing political boundaries while avoiding gerrymandering. This writeup is available on GitHub, or my personal website. Slides for this post are also available here Table of Contents …