Embedding Python

gavinpaterson gavinpaterson at yahoo.com
Tue May 9 04:39:40 EDT 2006


Dear Pythoners,

I am writing as I am having trouble embedding a Python program into a
Win XP C++ console application.

I have written a script file for importing and I am trying to use the
example for "Pure Embedding" found in the product documentation.

The program fails to successfully execute past the line:

if (pFunc && PyCallable_Check(pFunc))

I have checked the pFunc pointer at runtime and it is not null so I
assume that the PyCallable_Check fails.

If I define my function in python in file "multiply.py" as:

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

Then in VC++ I call the program with arguments:

multiply multiply 23 3

Then I'd expect a successful result, the file seems to be getting
parsed if multiply.pyc is available, but the function multiply does
not seem to be callable - where am I going wrong?









More information about the Python-list mailing list