У меня есть класс, определенный в feat.py
class feat:
def __init__(self):
print 'feat init '
pass
def do_something(self):
return true
Теперь я вызываю следующее:
from feat import *
f=feat()
for i in dir(f): #feature_functions:
i_str = str(i)
print 'f has this attribute', hasattr(f,i)
print 'f has attribute value', getattr(f,i)
Я получаю вывод:
feat init
f has this attribute True
f has attribute value >
Я попытался использовать i_str, как показано ниже
print 'f has this attribute', hasattr(f,i_str)
print 'f has attribute value', getattr(f,i_str)
Я получаю тот же вывод.
Разве вывод не должен выглядеть следующим образом?
f has this attribute True
f has attribute value <function do_something at 0x10b81db18>
Будет лиценю любое предложение.Я использую Python 2.7.