On 03/04/2010 01:59 PM, Neal Becker wrote:
OK. I had assumed, since it returned an object, that I could call a function and get back the python result. I didn't use eval, because eval is restricted to 1 expression, and so couldn't do something like: ''' sys.path.append('./') import module module.F (3)''' which is what I was trying to do
OK. If you want to do this once, this seems a good approach. However, for doing it repeatedly it might be better to first execute the "startup" code, such that "module" ends up in a dictionary ("global", in my case). Then you can run eval() on the expression you'd like to get the result of:
exec(code, global); for(...) { int result = extract<int>(eval("module.F(3)", global)); ... } Thus you only need to execute common startup code once. Stefan -- ...ich hab' noch einen Koffer in Berlin... _______________________________________________ Cplusplus-sig mailing list Cplusplus-sig@python.org http://mail.python.org/mailman/listinfo/cplusplus-sig