import python module from C++ code

Santoso Wijaya santoso.wijaya at gmail.com
Fri Mar 4 12:34:47 EST 2011


Extending an embedded Python is not that much different than extending
Python proper. There's even this section [1] in that documentation,
conveniently titled, "Extending Embedded Python."

~/santa

[1]
http://docs.python.org/extending/embedding.html#extending-embedded-python

On Fri, Mar 4, 2011 at 9:14 AM, Arthur Mc Coy <1984docmccoy at gmail.com>wrote:

> Yes, I did. Here the link
> http://docs.python.org/extending/extending.html#providing-a-c-api-for-an-extension-module
>
> It does not cover .py file embeding. So it is not my case.
>
>
> On Fri, Mar 4, 2011 at 7:03 PM, Santoso Wijaya <santoso.wijaya at gmail.com>wrote:
>
>> Have you read the doc [1] on extending/embedding Python?
>>
>> ~/santa
>>
>> [1] http://docs.python.org/extending/
>>
>> On Fri, Mar 4, 2011 at 8:27 AM, Arthur Mc Coy <1984docmccoy at gmail.com>wrote:
>>
>>> Hi all,
>>>
>>>
>>> I have a C++ application. I have a .cpp file which is not a main
>>> program, but a class where I want to call python script
>>> (doSomething.py file).
>>>
>>> I'm using embed python like in a tutorial here:
>>> http://www.codeproject.com/KB/cpp/embedpython_1.aspx
>>>
>>> But the tutorial is bad. It does not explain howto create python
>>> module which they call in their example. doSomething.py file contains
>>> two classes, one of them I use externally (its functions).
>>>
>>> So I need to PyImport_Import(py_module) by name of this py file, but
>>> when I try to do that it fails. Please, give me some examples.
>>>
>>>
>>> If needed, I can attach my code as well.
>>> Thank you, waiting for anybody's response!
>>> Be happy.
>>>
>>> Arthur
>>> --
>>> http://mail.python.org/mailman/listinfo/python-list
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110304/46c3b9bd/attachment-0001.html>


More information about the Python-list mailing list