Embedding Python in C++ Problem

gavinpaterson gavinpaterson at yahoo.com
Tue May 9 04:50:13 EDT 2006


Dear Pythoners,

I am trying to embed a Python script into a C++ application for the
first time.

Although I have used the example 5.3 Pure Embedding I am having
problems with calling the function defined in my program.

If I define function multiply in module "multiply.py"

def multiply(a,b):
    print "Will compute", a, "times", b
    c = 0
    for i in range(0, a):
        c = c + b
    return c

Then call the program with the following arguments:

multiply multiply 2 3

Then I'd expect to see the result appear in stdout. The compiled
module is found but the program fails to get past:

if (pFunc && PyCallable_Check(pFunc))

I am using VC7.1 on windows XP. Where am I going wrong?









More information about the Python-list mailing list