[英]Eclipse: while-loop does not work unless there is a print statement
[英]Why does my 'if' conditional not work unless I put a 'print' statement after the condition?
有关方法的开头:
def create_axial_features(self):
# begin executing features
try:
roto.command.CommandExecute('TREEVIEW OBJECT SELECT ALL')
roto.command.CommandExecute('ALIGN COORDINATE_SYSTEM ACTIVE ( "world" )')
roto.command.CommandExecute('EDIT OBJECT DELETE ()')
roto.command.CommandExecute(
'FEATURE PLANE CREATE ("Thrust End of Shaft")')
if self.var.jobDetails["Thrust Collar"] == "1":
roto.command.CommandExecute('FEATURE PLANE CREATE ("Inactive Thrust Shoulder")')
print "done"
roto.command.CommandExecute(
'FEATURE PLANE CREATE ("Active Thrust Shoulder")')
roto.command.CommandExecute(
'FEATURE CYLINDER CREATE ("TE Bearing Journal")')
由于某种原因,仅当我在下面添加print
语句时, if
语句下的代码才会执行。 当我删除print
语句时,“非活动推力凸肩”行将无法执行。 是的, self.var.jobDetails["Thrust Collar"]
始终等于1,所以绝对不是。
我以前从未遇到过这样的问题,因此对于从哪里开始进行故障排除,我感到茫然。 任何帮助表示赞赏。
我发现了问题
它与以下行有关:
if self.var.jobDetails["Thrust Collar"] == "1":
当开始新作业时,值"1"
作为整数存储,因为它只是由用户输入的。 但是,当加载旧作业时,它将以值的形式从保存的文本文件中加载该值。 因此, if
条件语句仅在已加载作业时运行。 我错误地将其归因于内存缓冲问题,因为我在第一次测试期间创建了新工作,并在第二次测试中简单地加载了该工作,而在我看来,我在第一次和第二次测试之间的代码本身发生的唯一变化是添加print
声明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.