Hans Meine wrote:
>I don't see the problem. AFAICS, "ask for a function by name" is "ask python
>[i.e. callout to python] for a function [which is an object that I can safe
>when I want to call it repeatedly] by name". Which part could be simpler?
As best I could figure, I needed to write Python code, execute a script file,
get that code to call a C function that I register, in order to have that
function. At least the tutorial implied that was the way.
Gustavo gives a better approach. Thanks.
Alan Baljeu
________________________________
From: Gustavo Carneiro <[EMAIL PROTECTED]>
To: Development of Python/C++ integration <cplusplus-sig@python.org>
Sent: Thursday, November 13, 2008 9:48:43 AM
Subject: Re: [C++-sig] looking up functions
2008/11/13 Alan Baljeu <[EMAIL PROTECTED]>
I'm reading the Python extension tutorial, and I cannot believe the embedding
section. It tells me the only way to call a python function is to callout to
python to pass back a function object which I then save so I can call it when I
need to. This seems ridiculous. Surely there is a way to obtain Python
function objects without going through that! Does somebody have a way to ask
for a function by name?
PyObject *function_object = PyObject_GetAttrString (PyModule_Import
("modulename"), "function_name");
Leaks a module object reference, but you get the idea...
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
__________________________________________________________________
Get a sneak peak at messages with a handy reading pane with All new Yahoo!
Mail: http://ca.promos.yahoo.com/newmail/overview2/
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig