class K(object): def __init__(self, s="FLFRFLFRFLFRFLFRFLFRFLF", i=1): self.kf = s self.i = i def __xor__(self, o): return K(self.kf.replace("F", "FLFRFLF"), self.i+1) def __nonzero__(self): import turtle k_ = turtle.Turtle() turtle.resetscreen() turtle.title("Iteration: %d" % self.i) k_.ht() turtle.setup(400, 400) k_.down() k_.speed('fastest') k_.penup() k_.goto(-150, 100) k_.pendown() for move in self.kf: if move == "F": k_.forward(100.0 / (3 ** (self.i - 1))) elif move == "L": k_.left(60) elif move == "R": k_.right(120) return 0 k = K()