0
我已经在项目开始时设置了一个全局变量删除,位于导入的库之下和任何类之前,但是当我有这样的代码时:在为全局变量赋值之前引用的局部变量'delete'
def motion_notify_callback(event):
if (ispymol == True):
if event.inaxes is ax:
x = event.xdata
y = event.ydata
x = round(x,0)
y = round(y,0)
x = int(x)
y = int(y)
coord = (x,y)
for i in range(0,len(number_list)):
if (coord == number_list[i]):
if (delete == True):
pymol.cmd.do("delete CurrentCont")
delete = False
pymol.cmd.do("distance CurrentCont, chain"+lc+" and resi "+resi1[i]+" and name CA, chain"+lc+" and resi "+resi2[i]+" and name CA")
delete = True
for i in range(0,len(rres)):
if (coord == mappingpredcont[i]):
if (delete == True):
pymol.cmd.do("delete CurrentCont")
delete =False
pymol.cmd.do("distance CurrentCont, chain"+lc+" and resi "+predresi1[i]+" and name CA, chain"+lc+" and resi "+predresi2[i]+" and name CA")
delete = True
在赋值给全局变量之前引用了错误局部变量'delete' 我在哪里出错了?
你必须在你想使用它的每个函数中定义'global'(提醒你在所有使用情况中大于99%都是错误的编码风格)。 – Matthias 2013-04-26 09:24:08