Updated to match blog, added Python equivalents