Josh Munn's Website

Python

Working with wagtail-factories block factories

Wagtail’s killer feature is the stream field system for flexible content. In this tutorial we will learn how to create and use factory classes that enable us to generate content for stream field blocks, just like we would with factories for Django models.

Getting started with wagtail-factories

In this tutorial, we will learn how to use the wagtail-factories library to create factory boy factories for a Wagtail project. These factories facilitate the easy creation of model instances, which is particularly useful for tests.

We’ll learn about factories for Wagtail’s models - factories for stream field blocks will be covered in another document.

Rewriting a recursive Python function as an abstract machine

Silhouette of a person standing by a tree on a hill

The miniKanren paper (Will Byrd’s thesis) describes walk*, which is used to deeply walk some term with regards to a substitution. That means that if a given term is not atomic (e.g. it’s a list), it will walk all of its sub-terms, recursively. Here’s a naive translation to Python:

2023 Talk: Infinite Pizza

In November 2023 I gave a talk at a Torchbox internal tech team conference day. The talk was titled “Infinite Pizza”, and was an introduction to logic programming, using Python.

The slides can be viewed at https://microkanren-talk.joshuamunn.com/.

Why I'm Rewriting Microkanren

I’m rewriting my Python microkanren implementation. I’ve always wanted to add tabling, have tried a few times, but stopped due to lack of time, and subtle errors. I’m taking a few steps to simplify the core implementation, and get tabling done.

Microkanren, Cons and Python

I’ve been implementing µKanren in Python. One challenge so far has been creating a sequence abstraction with semantics similar to Lisp lists. This is important as it’s necessary to be able to decompose sequences into parts for unification, such that:

A Python Quine

Here’s a Python 3 quine I wrote:

(q:='(q:={q!r},print(f{q!r}))',print(f'(q:={q!r},print(f{q!r}))'))