仅寻求减少嵌套语句的技巧和技术:
下面的脚本在初始移动后会更新变量x的位置:
转到P1->更新到P2->调用时转到P2->更新到P_n + 1->调用时转到P_n + 2
必要时中断。
x = [P1,P2,P3]
def function(self):
global x
for self.position in x:
self.var = object
self.var.angle = self.position
if self.position == P1:
x = [P2,0]
# other stuff
break
if self.position == P2:
x0 = [P3,0]
# other stuff
if self.position == P3:
x0 = [90,0]
# other stuff
break