Convert spiral.c to python