I am using Python 2.7. It is not clear to me how to embed Python inside C++ as found here: http://docs.python.org/2.7/extending/embedding.html.
I have a simple python example here in a file named test.py:
class math:
#def __init__(self):
def add(self, num1, num2):
return num1 + num2
def subtract(self, num1, num2):
return num1 - num2
From python, I would do something like this:
>>> from test import math
>>> m = math()
>>> a = m.add(1, 2)
>>> s = m.subtract(1, 2)
I have the beginning of some C++ code to do this:
PyObject *pName, *pModule;
Py_Initialize();
pName = PyString_FromString("test");
pModule = PyImport_Import(pName);
That seems to work just fine. But, that seems to be the equivalent of doing this in Python:
import test
How do I import the Python class math?
Thanks