[C++-sig] How do I wrap a C++ object to a PyObject*
Ralf W. Grosse-Kunstleve
rwgk at yahoo.com
Thu Oct 31 10:56:28 CET 2002
--- David Abrahams <dave at boost-consulting.com> wrote:
> "Bjorn Pettersen" <BPettersen at NAREX.com> writes:
> > I've looked through the documentation but haven't found anything
> > obvious...
>
> Let's see. You have a wrapped C++ class somewhere?
> If so, you can write in __main__:
>
> import some_boost_python_module
> x = some_boost_python_module.some_class(some_arg)
>
> But this is trivially explained in the docs, so you must mean
> something else...
I believe he wants to do this from C++. I don't know what __main__
is, but I am guessing that his problem is solved by using a
construct like this:
scope().attr("key") = value;
which I believe is just a shorthand for
scope().attr("key") = object(value);
This sets an attribute in the importing module.
value can be any object that is convertible from C++ to Python,
including but not limited to instances of a user-defined classes
X with a corresponding class_<X> statement.
Ralf
__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/
More information about the Cplusplus-sig
mailing list