Python3 rewrite of swirl