I have a class defined in feat.py
class feat:
def __init__(self):
print 'feat init '
pass
def do_something(self):
return true
Now I am calling the following:
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)
I am getting output:
feat init f has this attribute True f has attribute value >
I tried using i_str like the following
print 'f has this attribute', hasattr(f,i_str)
print 'f has attribute value', getattr(f,i_str)
I am getting the same output.
Shouldn't the output look like the following?
f has this attribute True f has attribute value <function do_something at 0x10b81db18>
Would appreciate any suggestion. I am using Python 2.7.