expose C++ functions in python and embed python in C++
<p>My app have some events, each event can have some actions. These actions is implemented in C++. I want to expose those core functions to python and use python to write the action. The advantage is I can modify actions without recompile. For example:</p>

<pre><code>CppClass o;

// --- this is a action----
o.f1();
o.f2();
// ------------------------
</code></pre>

<p>use python to script the action:</p>

<pre><code>def action1(o):
    o.f1()
    o.f2()
</code></pre>

<p>In c++, use interpreter to run this script, find action1 and call it with a PyObject which convert from c++ object. Actually, I have not expose f1() &amp; f2() to python, I just use python to regroup the definition of action, all function is running by c++ binary code. Notice that I have not to give a definition of f1() &amp; f2() in python.</p>

<p>The problem is: how I expose global functions? such as:</p>

<pre><code>def action2():
    gf1()
    gf2()
</code></pre>

<p>boost::python can expose function, but it is different, it need compile a DLL file and the main() is belong to python script. Of course I can make global functions to be a class static member, but I just want to know. Notice that I HAVE TO give a definition of gf1() &amp; gf2() in python.</p>

<p>Jython can do this easily: just import Xxx in python code and call Xxx.gf1() is ok. But in cython, how I define gf1() in python? This is a kind of extension, but extension requires Xxx be compiled ahead. It seems only way is make gf() into a class?</p>
