2
我在一个文件中有一个函数,我正在调用一个单独的脚本(如下所示)。直接从函数打印工作正常,但是当我尝试将值返回给脚本时,它会发送'None'。返回的字典值是'None'python
任何帮助,将不胜感激。 感谢
脚本:
import modules.functions as f
restype = 'THR'
atomtype = 'CA'
print f.AtomType(restype,atomtype)
功能:(这是一个返回值的函数的一部分)
def AtomType(resName,atomType):
def threonine():
print 'well im here'
atoms = {'N' : 1,
'CA': 6,
'C' : 8,
'O' : 2,
'CB': 6,
'OG1': 1,
'CG2': 4,
}
print atoms[atomType]
return atoms[atomType]
residues = {'ALA' : hydrophobic,
'ARG' : arginine,
'ASN' : asparagine,
'ASP' : aspartate,
'CYS' : cysteine,
'GLN' : glutamine,
'GLU' : glutamate,
'GLY' : hydrophobic,
'HIS' : histidine,
'ILE' : hydrophobic,
'LEU' : hydrophobic,
'LYS' : lysine,
'MET' : methionine,
'PHE' : phenylalanine,
'PRO' : proline,
'SER' : serine,
'THR' : threonine,
'TRP' : tryptophan,
'TYR' : tyrosine,
'VAL' : hydrophobic,
}
residues[resName]()
和输出我得到的是:
well im here
6
None
编辑:增加了整个功能
第一个代码片段不会在第二个代码片段中调用该函数。第二个片段中的函数不接受任何参数,但无论如何都会访问一些神秘的'atomType'。这有点令人困惑......也许你可以发布你真的*试图运行的代码? – 2011-03-28 16:11:48
你能告诉我们一段完整的代码来重现错误吗? – 2011-03-28 16:12:16
您正在调用'f.AtomType'并发布'threonine()'的代码。请发布'f.AtomType()'的代码' – pajton 2011-03-28 16:13:27