Author: Andrei Fortuna
Date: 14:41:56 01/15/04
Go up one level in this thread
On January 15, 2004 at 16:17:52, Omid David Tabibi wrote:
>I guess I should give it a try. You know of any good tutorial websites?
For python : see the main site, www.python.org - for tutorials and books. And
there is among others the free e-book Dive Into Python at :
http://diveintopython.org/ . I found the newsgroup comp.lang.python a very
friendly place to find answers to my python questions.
For wxWindows : www.wxwindows.org for the original site and www.wxpython.org for
the python distribution. There are lots of samples in the downloadable wxPython
distibution. I usually just use the wx help (which shows the C++ syntax for
functions and have special notes for wxPython where is something different).
>And, is it possible to acces a dll from Python? As I always write the core of my
>programs in C/C++ anyway, regardless of the GUI language.
Sure ! I found out it's very easy to make a python C/C++ extension (a dll
renamed to .pyd) using Boost.Python (www.boost.org). For example compiling the
following program :
#include <boost/python.hpp>
using namespace boost::python;
char const* greet()
{
return "hello, world";
}
BOOST_PYTHON_MODULE(hello)
{
def("greet", greet);
}
results in a dll. Copying this to python's library directory I can call my
function from python like this :
import hello
print hello.greet()
and it will print my "hello, world" string
It does a bit of tinkering first time to get used on how to transmit parameters
to/from python and setting up boost but after that it gets easy. You can even
export C/C++ classes to be seen under python as python classes, without too many
changes in your code.
There are some other ways to bind python<->C/C++ (like SWIG and pyRex) but I
found boost to be very good and never investigatet something else.
Andrei
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.