在调试时,Spyder不会告诉我错误的位置。它在两个单独的行上两次说ipdb>。
我尝试使用ipdb进行操作,因为它似乎允许您通过控制台运行代码,但就如何以这种方式有效地调试...
我需要使用一个纯函数和一个主函数,但是现在看来,我的大部分纯函数代码似乎是多余的,因为我不确定如何在一个函数中调用函数与两个独立函数之间取得平衡所有变量均在Python中定义和识别的函数。
def main(mylist):
n= input("Enter number of binding sites:")
K= input("Enter binding site constant:")
x = input("Input genetic factor:")
a = input("Enter epigenetic correction: ")
for mylist in PaulingEq():
H=0 #Normal range in men 13.5-17.5 grams/deciliter
print("Number of binding sites: ", n)
print("Binding site constant: ", K)
print("Genetic factor: ", x)
print("Hemoglobin count: ", H = n/4)
print("Epigenetic correction: ", a)
print("\n")
if n%4 != 0:
response=input("Abnormal blood sample, enter y/n to continue: ")
if response=='y':
continue
print("Proceeding with calculations")
else:
print("Canceling program")
return
mylist = []
Y = ((1/n)*(K*x)+(3*a*K**2)*(x**2)+(3*a**3)*(K**3)*(x**3)+(a**6)*(K**4)*(x**4) ) / ( 1+ 4*K*(x)+(6*a*(K**2)*(x**2))+(4*a**3)*(K**3)*(x**3)+(a**6)*(K**4)(x**4) )
mylist= list.append(n,K,x,H,a,Y)
mylist= list.append(n,K,x,H,a,Y)
#n=mylist.pop(0)
#K=mylist.pop(1)
#x=mylist.pop(2)
#H=mylist.pop(3)
#a=mylist.pop(4)
Y=mylist.pop(5)
print("Oxygen affinity:", Y)
if __name__ == "__main__":
main(mylist)
def PaulingEq():
#Interpretation of Adair's equation
BiSi_open = True
while BiSi_open:
#The equation assumes subunits are arranged in a square
#The equation provides a tetrahedral structure
#n= num_bisi #number of binding sites
#K= bisi_k #binding site constant
#x= genetic_factor
#Y= Oxygen_aff
#H= Hemoglobin_count
#a= epigenetic factors
for mylist in main(): #four oxygens for four binding sites in hemoglobin
n=mylist.pop(0)
K=mylist.pop(1)
x=mylist.pop(2)
a=mylist.pop(4)
H=mylist.pop(3)
for mylist in main():
Y = ((1/n)*(K*x)+(3*a*K**2)*(x**2)+(3*a**3)*(K**3)*(x**3)+(a**6)*(K**4)*(x**4) ) / ( 1+ 4*K*(x)+(6*a*(K**2)*(x**2))+(4*a**3)*(K**3)*(x**3)+(a**6)*(K**4)(x**4) )
mylist = []
mylist= list.append(n,K,x,H,a,Y)
BiSi_open=False
return mylist