472,354 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,354 software developers and data experts.

General questions about embedding Python.


I am currently studying how to embedd python. I am developing a
graphical C++ application. My goal is to embedd python script that will
control some kind of animation.
I have some questions about python embedding:

1) Is there a good text book or other resource on embedding/extending?
(I find it hard to learn only by the tutorial and C/Python API from the
python.org site)

2) I have found that there are many ways to embedd a script:
What are the cons and pros of using each of them?

3) Is there a problem with the PyRun_SimpleFile(). I am trying to run
the following code:

const char *SCRIPT_NAME = "C:\\test_script.py";

int _tmain(int argc, _TCHAR* argv[])

FILE *script_file;
script_file = fopen(SCRIPT_NAME, "r");

if (script_file != NULL)
PyRun_SimpleFile(script_file, SCRIPT_NAME);

return 0;

The python script has only one line: 'print "hello"'

I build it with Python2.3 libraries. When I try to run the code I get
access violation.

4) What is the correct way to handle/catch python exceptions in the
embedding Python code?

Forgive me if I have asked too many questions in one eMail, it is
becuase I don't really know where to start learning this subject from.


Jul 21 '05 #1
1 1775
"amit" <am**@digitalpeers.com> wrote:

I am currently studying how to embedd python. I am developing a
graphical C++ application. My goal is to embedd python script that will
control some kind of animation.
I have some questions about python embedding:

Others will probably answer your specific questions, but I will ask you
another first: Why do you (think you) need to embed python in the first
place, as opposed to wrapping the low-level performance critical C++
animation code (through SWIG, Boost, or SIP or even use Pyrex), and
have python on top ? I know very little about embedding python other
than it is not considered a pleasant experience, so make sure you look
into the alternatives and have very good reasons if you decide to go
down this route.


Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: jordi | last post by:
Hi, I'm starting to use Python embedded in a C program. I'm using Python to execute several scripts using as a variables information retrieved for several multithread "agents" written in C. ...
by: Atul Kshirsagar | last post by:
I am embedding python in my C++ application. I am using Python *2.3.2* with a C++ extention DLL in multi-threaded environment. I am using SWIG-1.3.19 to generate C++ to Python interface. Now to...
by: Robey Holderith | last post by:
Anyone know a good way to embed python within python? Now before you tell me that's silly, let me explain what I'd like to do. I'd like to allow user-defined scriptable objects. I'd like to...
by: Martin | last post by:
Greetings, I am new to python and wish to embed python in an 3D graphics application to provide application automation. The high level goal is to be able to drive my app from a script for batch...
by: adsheehan | last post by:
Hi, I am embedding Python into a multi-threaded C++ application runnig on Solaris and need urgent clarification on the embedding architecture and its correct usage (as I am experience weird...
by: Kenneth McDonald | last post by:
We're looking at embedding Python into our product to provide users with the ability to write scripts for the programming. My knowledge of Python is excellent, I'm familiar with the concepts of...
by: Redefined Horizons | last post by:
I've got a third-part application that exposes a C API. I'd like to wrap it in Python. Is there a specific forum that covers extending and embedding Python, or are those type of questions O.K. on...
by: Qun Cao | last post by:
Hi Everyone, I am a beginner on cross language development. My problem at hand is to build a python interface for a C++ application built on top of a 3D game engine. The purpose of this python...
by: Tim Spens | last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote: I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.