3

How would I go about adding a script written in python to a c++ project? Thanks

Edit: Basically all the script does is email some data. I would like to pass the data and maybe the email address to a function written in python. Hope that clears things up..

1
  • 2
    You're going to need to be more specific. Does the C++ program need to run the script? Get variables back from the script? Or are you just trying to translate it to c++? Commented Apr 13, 2010 at 5:29

3 Answers 3

3

You could look at Boost.Python which is a "a C++ library which enables seamless interoperability between C++ and the Python programming language."

You have to be more specific, though.

Sign up to request clarification or add additional context in comments.

Comments

3

You may be interested in Boost.Python: Embedding the Interpreter, or Python/C API: Embedding the Python Interpreter. You can either use the Python C APIs directly or use the Boost.Python library as you so choose. You might also be interested in reading Embedding Python in Your C Programs which walks you through it.

Comments

1

The most primitve solution would be to use the system command to call you script, but that does limit your control over it to setting environment variables and passing parameters.

system("myscript.py param1 param2") 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.