[C++-sig] Re: Embedding example anyone?
David Abrahams
david.abrahams at rcn.com
Thu Jul 11 13:31:31 CEST 2002
From: "Berthold Höllmann" <hoel at germanlloyd.org>
<<I'm looking for a somehow different approach. We have to provide some
functionality for a C++ Program. The functions are already almost
written, but in Python. So we are looking for a easy/convenient way to
access Python code/classes/methods from C++. Is there anything
available to help us there.>>
Boost.Python v2 contains a class called "object" which lets you access
Python objects (including classes and methods) in C++ in almost the same
way you'd do it from Python. The only major syntactic differences are:
Python C++
x.foo x.attr("foo")
x[1:-2] x.slice(1,-2)
x[:-4] x.slice(_,-4)
Some of python's special syntax quirks are also not supported, i.e.
x < y < z
means:
(x < y) < z
not:
x < y and y < z
as it does in Python.
HTH,
Dave
More information about the Cplusplus-sig
mailing list