<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:10pt">Hans Meine wrote:<br>&gt;I don't see the problem.&nbsp; AFAICS, "ask for a function by name" is "ask python <br>&gt;[i.e. callout to python] for a function [which is an object that I can safe <br>&gt;when I want to call it repeatedly] by name".&nbsp; Which part could be simpler?<br><br>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.&nbsp; At least the tutorial implied that was the way.<br><br>Gustavo gives a better approach.&nbsp; Thanks.<br><div>&nbsp;</div>Alan Baljeu<div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><font size="2" face="Tahoma"><hr size="1"><b><span style="font-weight:
 bold;">From:</span></b> Gustavo Carneiro &lt;gjcarneiro@gmail.com&gt;<br><b><span style="font-weight: bold;">To:</span></b> Development of Python/C++ integration &lt;cplusplus-sig@python.org&gt;<br><b><span style="font-weight: bold;">Sent:</span></b> Thursday, November 13, 2008 9:48:43 AM<br><b><span style="font-weight: bold;">Subject:</span></b> Re: [C++-sig] looking up functions<br></font><br><br><br><div class="gmail_quote">2008/11/13 Alan Baljeu <span dir="ltr">&lt;<a rel="nofollow" ymailto="mailto:alanbaljeu@yahoo.com" target="_blank" href="mailto:alanbaljeu@yahoo.com">alanbaljeu@yahoo.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I'm reading the Python extension tutorial, and I cannot believe the embedding section. &nbsp;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. &nbsp;This seems ridiculous. &nbsp;Surely there is a way to obtain Python function objects without going through that! &nbsp;Does somebody have a way to ask for a function by name?</blockquote>
<div><br>PyObject *function_object = PyObject_GetAttrString (PyModule_Import ("modulename"), "function_name");<br><br>Leaks a module object reference, but you get the idea... <br></div></div><br>-- <br>
Gustavo J. A. M. Carneiro<br>INESC Porto, Telecommunications and Multimedia Unit<br>"The universe is always one step beyond logic." -- Frank Herbert<br>
</div></div></div><br>



      <hr size=1>Now with a new friend-happy design! Try the new <a href="http://ca.beta.messenger.yahoo.com/"><b>Yahoo! Canada Messenger</b></a></body></html>