Say I have the following class
class Test:
def TestFunc(self):
print 'this is Test::TestFunc method'
Now, I create an instance of the class Test
>>>
>>> t = Test()
>>>
>>> t
<__main__.Test instance at 0xb771b28c>
>>>
Now, the t.TestFunc
is represented as follows
>>>
>>> t.TestFunc
<bound method Test.TestFunc of <__main__.Test instance at 0xb771b28c>>
>>>
Now I am storing the Python
representation of t.TestFunc
to a string string_func
>>>
>>> string_func = str(t.TestFunc)
>>> string_func
'<bound method Test.TestFunc of <__main__.Test instance at 0xb771b28c>>'
>>>
Now, Is there a way, where I can get the function handle from the string <bound method Test.TestFunc of <__main__.Test instance at 0xb771b28c>>
. For example,
>>>
>>> func = xxx(string_func)
>>> func
<bound method Test.TestFunc of <__main__.Test instance at 0xb771b28c>>
>>>