Michele Petrazzo wrote:

Auto reply:

> I find this: http://tinyurl.com/nwbpk
> 

Following this link, here is my solution:


code = """
def funct2Call():
  return "It work!"

object.method(funct2Call)
"""

class Object(object):
     def method(self, value):
         self._callable = value
     def __call__(self):
         return self._callable()

# populate the namespace
namespace = {
     "object": Object()
     }

# execute the code
exec code in namespace

namespace["object"]()

Michele
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to