Calling Python script from C++

Joined
Feb 25, 2010
Messages
2
Reaction score
0
Hi,

We have a requirement of Calling Python script from C++.

So, For this we are trying to pass entire python script(Script has both method implementation and method calls are exist) as a string and executing this string by using PyRun_SimpleString().

Our concern is that if python has a method with no arguments we are able to execute it successfully

But If Method takes parameters or arguments ,then how do we can pass values to that method and how can we execute it?

Could you please provide the solution.

Thanks,
Lakshmi Narasaiah
 
Joined
Feb 25, 2010
Messages
2
Reaction score
0
Hi,

Here is the more elabaration.

The python file : Hello.py

Def sayHello(name):
Print "Hello" + name

sayHello(arg)

and

In c++ file, I am catching all the lines from the python file in string buffer and calling the PyRun_SimpleString(stringbuffer).
It is working fine without passing any argument. But I want to send the argument to this python file from c++ file.

Could you tell me how can I pass arguments to python file?

Thanks,
Lakshmi
 

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

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top