에 저장되어있는 메소드를 호출하는 방법 당신은 무엇을 시도하고, //TypeError: 'unicode' object is not callable
내가 얻을이 유니 코드 데이터 callable.The 오류를 만드는 방법을 이름이 다음 코드에서 변수
def test(test_config):
for i in test_config:
print i.header //prints func1
print type(i.header) // prints unicode
try:
#i.header()//TypeError: 'unicode' object is not callable
func = globals()[i.header]
print func # found it
func()
except AttributeError:
logging.error("Method %s not implemented"%(i.header))
def func1():
print "In func1"
test(u'func1')
당신이 그 * 이름은'i.header' 변수에 의해 참조 * 메서드를 호출하려고 여부는 분명이 방법은? – shx2
업데이트 된 질문 – Rajeev
을 참조하십시오. 전화를 걸 때 무엇을 기대합니까? –