Embedding Python

G

gavinpaterson

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?
 
S

Serge Orlov

gavinpaterson said:
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.

Looking at the source in "Pure Embedding" I see that it is supposed to
print an error message if PyCallable_Check fails, have you got the
message?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,295
Latest member
EmilG1510

Latest Threads

Top