Microsoft Visual C++ and pyton

Christopher De Vries devries at idolstarastronomer.com
Mon Jan 31 11:26:45 EST 2005


On Sun, Jan 30, 2005 at 03:12:06PM -0800, mike wrote:
> I am new with python.  Is it possible to have an MFC application and
> develop some module using python? what are the steps in doing this? can
> anybody give me a url or some documentation for this.. thanks..

It is possible to embed python in a C or C++ application, enabling you to call
python functions from C. I would recommend reading "Extending and Embedding the
Python Interpreter" at http://docs.python.org/ext/ext.html for more
information. If you are currently using Visual C++ 6.0, either stick with
Python 2.3 or read this: http://www.vrplumber.com/programming/mstoolkit/ to
learn how to build extensions for python 2.4 with the free VC++ toolkit
compiler. If you are already using version 7 of the Microsoft C++ compiler then
you should have no problems with Python 2.4. 

I usually do not embed the interpreter, but I have written some extension
modules... well, I should say I have used SWIG (http://www.swig.org/) to create
wrappers around some C libraries. For information (read: rants) on extending
versus embedding see http://twistedmatrix.com/users/glyph/rant/extendit.html
and http://c2.com/cgi/wiki?EmbedVsExtend . 

You can also use win32 python extensions to make your module available through
COM, but I don't know anything about that.

Chris



More information about the Python-list mailing list