python port credit to scturtle